rick commited on
Commit
45e8773
·
unverified ·
1 Parent(s): e9d85ac
Files changed (1) hide show
  1. pages/main.py +13 -6
pages/main.py CHANGED
@@ -139,13 +139,20 @@ def transcribe_audio(filepath: Union[str, IO], language: Optional[str] = None) -
139
  segment.export(buffer, format="mp3")
140
  buffer.seek(0)
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
- response = client.audio.transcriptions.create(
144
- model="whisper-1",
145
- file=("audio.mp3", buffer),
146
- language=language,
147
- response_format="text"
148
- )
149
  transcriptions.append(response)
150
 
151
  return " ".join(transcriptions)
 
139
  segment.export(buffer, format="mp3")
140
  buffer.seek(0)
141
 
142
+ if not( language ):
143
+ response = client.audio.transcriptions.create(
144
+ model="whisper-1",
145
+ file=("audio.mp3", buffer),
146
+ response_format="text"
147
+ )
148
+ else:
149
+ response = client.audio.transcriptions.create(
150
+ model="whisper-1",
151
+ file=("audio.mp3", buffer),
152
+ language=language,
153
+ response_format="text"
154
+ )
155
 
 
 
 
 
 
 
156
  transcriptions.append(response)
157
 
158
  return " ".join(transcriptions)