Spaces:
Paused
Paused
rick
commited on
Ajout du selecteur de voix pour le module TTS
Browse files
app.py
CHANGED
|
@@ -93,7 +93,7 @@ def language_detection(input_text, temperature=0.01):
|
|
| 93 |
def text_to_speech(text):
|
| 94 |
response = client.audio.speech.create(
|
| 95 |
model="tts-1",
|
| 96 |
-
voice=
|
| 97 |
input=text
|
| 98 |
)
|
| 99 |
|
|
@@ -209,6 +209,9 @@ def main():
|
|
| 209 |
if "enable_tts_for_input_from_audio_record" not in st.session_state:
|
| 210 |
st.session_state["enable_tts_for_input_from_audio_record"] = True
|
| 211 |
|
|
|
|
|
|
|
|
|
|
| 212 |
def init_process_mode():
|
| 213 |
# Configuration du mode de traduction si nécessaire
|
| 214 |
if "translation" == st.session_state["process_mode"]:
|
|
@@ -323,7 +326,25 @@ def main():
|
|
| 323 |
key="enable_tts_for_input_from_audio_record",
|
| 324 |
value=st.session_state.enable_tts_for_input_from_audio_record
|
| 325 |
)
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
|
| 328 |
# Point d'entrée de l'application
|
| 329 |
if __name__ == "__main__":
|
|
|
|
| 93 |
def text_to_speech(text):
|
| 94 |
response = client.audio.speech.create(
|
| 95 |
model="tts-1",
|
| 96 |
+
voice=st.session_state.tts_voice,
|
| 97 |
input=text
|
| 98 |
)
|
| 99 |
|
|
|
|
| 209 |
if "enable_tts_for_input_from_audio_record" not in st.session_state:
|
| 210 |
st.session_state["enable_tts_for_input_from_audio_record"] = True
|
| 211 |
|
| 212 |
+
if "tts_voice" not in st.session_state:
|
| 213 |
+
st.session_state.tts_voice = "onyx"
|
| 214 |
+
|
| 215 |
def init_process_mode():
|
| 216 |
# Configuration du mode de traduction si nécessaire
|
| 217 |
if "translation" == st.session_state["process_mode"]:
|
|
|
|
| 326 |
key="enable_tts_for_input_from_audio_record",
|
| 327 |
value=st.session_state.enable_tts_for_input_from_audio_record
|
| 328 |
)
|
| 329 |
+
|
| 330 |
+
with st.container(border=True):
|
| 331 |
+
st.subheader("Paramètres TTS")
|
| 332 |
+
st.selectbox(
|
| 333 |
+
"Choisissez la voix TTS",
|
| 334 |
+
options=["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
|
| 335 |
+
index=3, # "onyx" est à l'index 3
|
| 336 |
+
key="tts_voice"
|
| 337 |
+
)
|
| 338 |
+
st.checkbox(
|
| 339 |
+
"Activer TTS pour les entrées textuelles",
|
| 340 |
+
key="enable_tts_for_input_from_text_field",
|
| 341 |
+
value=st.session_state.enable_tts_for_input_from_text_field
|
| 342 |
+
)
|
| 343 |
+
st.checkbox(
|
| 344 |
+
"Activer TTS pour les entrées audio",
|
| 345 |
+
key="enable_tts_for_input_from_audio_record",
|
| 346 |
+
value=st.session_state.enable_tts_for_input_from_audio_record
|
| 347 |
+
)
|
| 348 |
|
| 349 |
# Point d'entrée de l'application
|
| 350 |
if __name__ == "__main__":
|