Files
ths-speech/python-server/speech.py
Yannik Schmidt fe3d6cadc6 refactor
2020-02-09 02:17:26 +01:00

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)