Tijs Zwinkels
commited on
Commit
·
922ad18
1
Parent(s):
f0a24cd
Make OpenAI backend work with language autodetect
Browse files- whisper_online.py +5 -5
whisper_online.py
CHANGED
@@ -152,12 +152,12 @@ class FasterWhisperASR(ASRBase):
|
|
152 |
class OpenaiApiASR(ASRBase):
|
153 |
"""Uses OpenAI's Whisper API for audio transcription."""
|
154 |
|
155 |
-
def __init__(self, lan=None,
|
156 |
self.logfile = logfile
|
157 |
|
158 |
self.modelname = "whisper-1"
|
159 |
-
self.
|
160 |
-
self.response_format =
|
161 |
self.temperature = temperature
|
162 |
|
163 |
self.load_model()
|
@@ -213,8 +213,8 @@ class OpenaiApiASR(ASRBase):
|
|
213 |
"temperature": self.temperature,
|
214 |
"timestamp_granularities": ["word", "segment"]
|
215 |
}
|
216 |
-
if self.task != "translate" and self.
|
217 |
-
params["language"] = self.
|
218 |
if prompt:
|
219 |
params["prompt"] = prompt
|
220 |
|
|
|
152 |
class OpenaiApiASR(ASRBase):
|
153 |
"""Uses OpenAI's Whisper API for audio transcription."""
|
154 |
|
155 |
+
def __init__(self, lan=None, temperature=0, logfile=sys.stderr):
|
156 |
self.logfile = logfile
|
157 |
|
158 |
self.modelname = "whisper-1"
|
159 |
+
self.original_language = None if lan == "auto" else lan # ISO-639-1 language code
|
160 |
+
self.response_format = "verbose_json"
|
161 |
self.temperature = temperature
|
162 |
|
163 |
self.load_model()
|
|
|
213 |
"temperature": self.temperature,
|
214 |
"timestamp_granularities": ["word", "segment"]
|
215 |
}
|
216 |
+
if self.task != "translate" and self.original_language:
|
217 |
+
params["language"] = self.original_language
|
218 |
if prompt:
|
219 |
params["prompt"] = prompt
|
220 |
|