mirror of
https://github.com/FAUSheppy/ths-speech
synced 2025-12-08 06:31:35 +01:00
small fixes
This commit is contained in:
@@ -1,15 +1,29 @@
|
||||
import speech
|
||||
import filesystem
|
||||
|
||||
MAIN_DIR = b"data/"
|
||||
|
||||
def parse_request(data):
|
||||
''' parse request and call correct function '''
|
||||
|
||||
# echo/test connection
|
||||
# echo/test connection #
|
||||
cleared_data = is_data_type(b"ECHOREQUEST,",data)
|
||||
if cleared_data:
|
||||
return cleared_data
|
||||
|
||||
# handle audio transmission #
|
||||
cleared_data = is_data_type(b"AUDIO_TRANSMISSION,",data)
|
||||
if cleared_data:
|
||||
with open("test.wav","wb") as f:
|
||||
f.write(cleared_data)
|
||||
return b"SUCCESS"
|
||||
filename = None
|
||||
try:
|
||||
filename, base64_string = cleared_data.split(b',')
|
||||
filename = MAIN_DIR + filename.split(b"/")[-1] + b".wav"
|
||||
filename = filename.decode("utf-8")
|
||||
except ValueError:
|
||||
return b"ERROR_MALFORMED_REQUEST"
|
||||
ret = filesystem.save_audio(filename, base64_string)
|
||||
speech.async_create_transcript(filename)
|
||||
return ret
|
||||
|
||||
# other shit
|
||||
return b"UNRECOGNIZED_SERVER_OPTION\n"
|
||||
|
||||
Reference in New Issue
Block a user