mirror of
https://github.com/SevaSk/ecoute.git
synced 2024-12-18 20:27:56 +00:00
fixed files opening and closing improperly
This commit is contained in:
parent
46d37a3df9
commit
6a20d04080
@ -48,10 +48,11 @@ class AudioTranscriber:
|
||||
|
||||
text = ''
|
||||
temp_file = NamedTemporaryFile(delete=False, suffix=".wav")
|
||||
temp_file.close()
|
||||
|
||||
source_info["process_data_func"](source_info["last_sample"], temp_file.name)
|
||||
text = self.audio_model.get_transcription(temp_file.name)
|
||||
|
||||
temp_file.close()
|
||||
os.unlink(temp_file.name)
|
||||
|
||||
if text != '' and text.lower() != 'you':
|
||||
|
@ -24,11 +24,10 @@ class WhisperTranscriber:
|
||||
|
||||
class APIWhisperTranscriber:
|
||||
def get_transcription(self, wav_file_path):
|
||||
audio_file= open(wav_file_path, "rb")
|
||||
try:
|
||||
result = openai.Audio.translate("whisper-1", audio_file)
|
||||
with open(wav_file_path, "rb") as audio_file:
|
||||
result = openai.Audio.translate("whisper-1", audio_file)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return ''
|
||||
|
||||
return result['text'].strip()
|
Loading…
Reference in New Issue
Block a user