Spaces:
Paused
Paused
rick
commited on
...not done...
Browse files- pages/main.py +24 -10
pages/main.py
CHANGED
|
@@ -122,12 +122,20 @@ def transcribe_segment(segment_data: Union[str, bytes], language: Optional[str]
|
|
| 122 |
audio_segment.write(segment_data)
|
| 123 |
|
| 124 |
audio_segment.seek(0)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
audio_segment.close()
|
| 132 |
return transcript
|
| 133 |
except Exception as e:
|
|
@@ -166,10 +174,16 @@ def transcribe_audio(audio_data: Union[str, bytes], language: Optional[str] = No
|
|
| 166 |
full_transcript = ""
|
| 167 |
for i, segment in enumerate(segments):
|
| 168 |
status.update(label=f"Transcription du segment {i+1}/{len(segments)}...")
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
full_transcript += f"{transcript} "
|
| 174 |
status.update(label="Transcription terminée", state="complete")
|
| 175 |
|
|
|
|
| 122 |
audio_segment.write(segment_data)
|
| 123 |
|
| 124 |
audio_segment.seek(0)
|
| 125 |
+
if not (language):
|
| 126 |
+
transcript = client.audio.transcriptions.create(
|
| 127 |
+
model="whisper-1",
|
| 128 |
+
file=audio_segment,
|
| 129 |
+
response_format="text"
|
| 130 |
+
)
|
| 131 |
+
else:
|
| 132 |
+
transcript = client.audio.transcriptions.create(
|
| 133 |
+
model="whisper-1",
|
| 134 |
+
file=audio_segment,
|
| 135 |
+
language=language, # semble que language soit mal formatter au format ISO6391
|
| 136 |
+
response_format="text"
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
audio_segment.close()
|
| 140 |
return transcript
|
| 141 |
except Exception as e:
|
|
|
|
| 174 |
full_transcript = ""
|
| 175 |
for i, segment in enumerate(segments):
|
| 176 |
status.update(label=f"Transcription du segment {i+1}/{len(segments)}...")
|
| 177 |
+
if not (language):
|
| 178 |
+
transcript = transcribe_segment(
|
| 179 |
+
base64.b64decode(segment.encode())
|
| 180 |
+
)
|
| 181 |
+
else:
|
| 182 |
+
transcript = transcribe_segment(
|
| 183 |
+
base64.b64decode(segment.encode()),
|
| 184 |
+
language=language
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
full_transcript += f"{transcript} "
|
| 188 |
status.update(label="Transcription terminée", state="complete")
|
| 189 |
|