nit: remove temp output file

This commit is contained in:
Shiven Mian 2024-02-10 11:49:08 -08:00
parent 43108e931d
commit c9b3608b38
2 changed files with 7 additions and 4 deletions

View File

@ -1 +1 @@
[{"role": "user", "type": "message", "content": " Hello, how you doing?\n"}]
[{"role": "user", "type": "message", "content": " Hey, how you doing?\n"}]

View File

@ -88,10 +88,13 @@ def stt_wav(wav_file_path: str):
return transcript
else:
temp_dir = tempfile.gettempdir()
output_path = os.path.join(temp_dir, f"output_{datetime.now().strftime('%Y%m%d%H%M%S%f')}.wav")
output_path = os.path.join(temp_dir, f"output_stt_{datetime.now().strftime('%Y%m%d%H%M%S%f')}.wav")
ffmpeg.input(wav_file_path).output(output_path, acodec='pcm_s16le', ac=1, ar='16k').run()
transcript = get_transcription_file(output_path)
print("Transcription result:", transcript)
try:
transcript = get_transcription_file(output_path)
print("Transcription result:", transcript)
finally:
os.remove(output_path)
return transcript
def stt(input_data, mime_type="audio/wav"):