mirror of
https://github.com/FAUSheppy/ths-speech
synced 2025-12-06 20:21:37 +01:00
24 lines
680 B
Python
24 lines
680 B
Python
import multiprocessing as mp
|
|
import os.path
|
|
import filesystem
|
|
import log
|
|
import transcribe
|
|
|
|
USE_FREE=False
|
|
USE_PAID=True
|
|
|
|
def asyncCreateTranscript(filename):
|
|
mp.Process(target=createAndSaveTranscript, args=(filename,)).start()
|
|
|
|
def createAndSaveTranscript(filename):
|
|
if no hasTranscript(filename):
|
|
try:
|
|
string = transcribe.transcribeFile(filename)
|
|
except spr.UnknownValueError:
|
|
log.log("Audio file is broken or not an audio file.")
|
|
raise e
|
|
except spr.RequestError as e:
|
|
log.log("Could not connect to google API: {}".format(e))
|
|
raise e
|
|
filesystem.saveTranscript(filename, string)
|