Spaces:
Paused
Paused
rick
commited on
v1.2.11
Browse files- pages/main.py +21 -17
pages/main.py
CHANGED
|
@@ -15,6 +15,7 @@ from typing import Optional
|
|
| 15 |
from typing import Tuple
|
| 16 |
from typing import Union
|
| 17 |
from io import BytesIO
|
|
|
|
| 18 |
|
| 19 |
# Third-party libraries
|
| 20 |
import requests
|
|
@@ -483,26 +484,29 @@ def recorder_released():
|
|
| 483 |
# PyDub handles time in milliseconds
|
| 484 |
ten_minutes = 10 * 60 * 1000
|
| 485 |
first_ten_minutes_audio = audio[:ten_minutes]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
input_text = transcribe_audio(tmp_extract),
|
| 497 |
-
temperature = 0.01
|
| 498 |
-
)
|
| 499 |
-
first_ten_minutes_audio = AudioSegment.empty()
|
| 500 |
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
)
|
| 505 |
)
|
|
|
|
| 506 |
|
| 507 |
|
| 508 |
# ##############################################################
|
|
|
|
| 15 |
from typing import Tuple
|
| 16 |
from typing import Union
|
| 17 |
from io import BytesIO
|
| 18 |
+
from copy import deepcopy
|
| 19 |
|
| 20 |
# Third-party libraries
|
| 21 |
import requests
|
|
|
|
| 484 |
# PyDub handles time in milliseconds
|
| 485 |
ten_minutes = 10 * 60 * 1000
|
| 486 |
first_ten_minutes_audio = audio[:ten_minutes]
|
| 487 |
+
else:
|
| 488 |
+
# less than ten minutes ... nervermind, the name of this variable is
|
| 489 |
+
first_ten_minutes_audio = deepcopy(audio)
|
| 490 |
+
|
| 491 |
+
with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as tmp_extract:
|
| 492 |
+
first_ten_minutes_audio.export(tmp_extract, format="mp3")
|
| 493 |
+
tmp_extract.close()
|
| 494 |
|
| 495 |
+
# il faut transcrire sans specifier l'argument language dans la fonction transcribe_audio
|
| 496 |
+
# ensuite on pourra utiliser la fonction detect_language pour detecter la langue du texte transcrit
|
| 497 |
+
|
| 498 |
+
# Transcrire les 10 premiers minutes audio en texte
|
| 499 |
+
st.session_state.language_detected = detect_language(
|
| 500 |
+
input_text = transcribe_audio(tmp_extract),
|
| 501 |
+
temperature = 0.01
|
| 502 |
+
)
|
| 503 |
+
first_ten_minutes_audio = AudioSegment.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
|
| 505 |
+
st.markdown(
|
| 506 |
+
f"- {get_translation('langue_detectee')}".format(
|
| 507 |
+
f"{convert_iso6391_to_language_name(st.session_state.language_detected)}"
|
|
|
|
| 508 |
)
|
| 509 |
+
)
|
| 510 |
|
| 511 |
|
| 512 |
# ##############################################################
|