Add speaking endpoints and clean code.

This commit is contained in:
Cristiano Ferreira
2023-06-23 00:05:48 +01:00
parent a67f02ed78
commit 4e1ad6dc67
9 changed files with 274 additions and 89 deletions

View File

@@ -0,0 +1,11 @@
import whisper
import os
def speech_to_text(file_path):
if os.path.exists(file_path):
model = whisper.load_model("base")
result = model.transcribe(file_path, fp16=False, language='English', verbose=False)
return result["text"]
else:
print("File not found:", file_path)
raise Exception("File " + file_path + " not found.")