Commit
·
66dff0f
1
Parent(s):
7840aa5
replace openai library with whisper
Browse files- backend/audio_to_tgt.py +10 -7
backend/audio_to_tgt.py
CHANGED
@@ -1,14 +1,17 @@
|
|
1 |
from openai import OpenAI
|
|
|
2 |
import os
|
3 |
|
4 |
-
whisper_key = os.getenv("OPENAI_API_KEY")
|
5 |
-
client = OpenAI(api_key = whisper_key)
|
6 |
|
7 |
|
8 |
def src_audio_to_eng_translator(audio_file_input):
|
9 |
with open(audio_file_input, "rb") as audio_file:
|
10 |
-
transcription = client.audio.translations.create(
|
11 |
-
|
12 |
-
|
13 |
-
)
|
14 |
-
|
|
|
|
|
|
1 |
from openai import OpenAI
|
2 |
+
import whisper
|
3 |
import os
|
4 |
|
5 |
+
# whisper_key = os.getenv("OPENAI_API_KEY")
|
6 |
+
# client = OpenAI(api_key = whisper_key)
|
7 |
|
8 |
|
9 |
def src_audio_to_eng_translator(audio_file_input):
|
10 |
with open(audio_file_input, "rb") as audio_file:
|
11 |
+
# transcription = client.audio.translations.create(
|
12 |
+
# model="whisper-1",
|
13 |
+
# file=audio_file
|
14 |
+
# )
|
15 |
+
model = whisper.load_model("turbo")
|
16 |
+
result = model.transcribe(audio_file)
|
17 |
+
return result.text
|