Spaces:
Paused
Paused
rick
commited on
bug fixed now... not done...
Browse files- pages/main.py +23 -3
pages/main.py
CHANGED
|
@@ -616,6 +616,10 @@ def main_page():
|
|
| 616 |
st.session_state.enable_tts_for_input_from_text_field,
|
| 617 |
system_prompt=system_prompt
|
| 618 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 619 |
response_status.update(label=f'({target_language_name}) - {get_translation("traduction_en_cours")}', state="running", expanded=True)
|
| 620 |
for response_chunk in response_generator:
|
| 621 |
message_placeholder.markdown(response_chunk)
|
|
@@ -627,9 +631,12 @@ def main_page():
|
|
| 627 |
if st.session_state.enable_tts_for_input_from_text_field:
|
| 628 |
response_status.update(label=f'({target_language_name}) - {get_translation("traduction_terminee")} ; {get_translation("synthese_vocale_en_cours")}', state="running", expanded=False)
|
| 629 |
tts_audio, tts_duration = process_tts_message(st.session_state.full_response)
|
|
|
|
| 630 |
if tts_audio:
|
| 631 |
st.audio(tts_audio, format="audio/mp3", autoplay=False)
|
| 632 |
audio_list.append((tts_audio, tts_duration))
|
|
|
|
|
|
|
| 633 |
response_status.update(label=f'({target_language_name}) - {get_translation("traduction_terminee")} ; {get_translation("synthese_vocale_terminee")}', state="complete", expanded=False)
|
| 634 |
else:
|
| 635 |
response_status.update(label=f'({target_language_name}) - {get_translation("erreur_synthese_vocale")}', state="error", expanded=False)
|
|
@@ -666,11 +673,20 @@ def main_page():
|
|
| 666 |
key=f"download_button_{langues}_{timestamp}",
|
| 667 |
)
|
| 668 |
|
| 669 |
-
|
| 670 |
audio_status.update(label=f"{get_translation('concatenation_audio_terminee')}", state="complete", expanded=True)
|
| 671 |
except Exception as e:
|
| 672 |
st.error(f"{get_translation('erreur_concatenation_audio')} : {str(e)}")
|
|
|
|
|
|
|
| 673 |
audio_status.update(label=f"{get_translation('erreur_concatenation_audio')} : {str(e)}", state="error", expanded=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 674 |
|
| 675 |
|
| 676 |
|
|
@@ -723,11 +739,15 @@ def main_page():
|
|
| 723 |
with st.chat_message("assistant", avatar="👻"):
|
| 724 |
message_placeholder = st.empty()
|
| 725 |
response_generator = process_message(
|
| 726 |
-
transcription, operation_prompt, st.session_state.enable_tts_for_input_from_audio_record
|
|
|
|
| 727 |
)
|
|
|
|
|
|
|
|
|
|
| 728 |
for response_chunk in response_generator:
|
| 729 |
message_placeholder.markdown(response_chunk)
|
| 730 |
-
|
| 731 |
if st.session_state.full_response != "":
|
| 732 |
message_placeholder.markdown(st.session_state.full_response)
|
| 733 |
|
|
|
|
| 616 |
st.session_state.enable_tts_for_input_from_text_field,
|
| 617 |
system_prompt=system_prompt
|
| 618 |
)
|
| 619 |
+
del system_prompt
|
| 620 |
+
del operation_prompt
|
| 621 |
+
del user_input
|
| 622 |
+
|
| 623 |
response_status.update(label=f'({target_language_name}) - {get_translation("traduction_en_cours")}', state="running", expanded=True)
|
| 624 |
for response_chunk in response_generator:
|
| 625 |
message_placeholder.markdown(response_chunk)
|
|
|
|
| 631 |
if st.session_state.enable_tts_for_input_from_text_field:
|
| 632 |
response_status.update(label=f'({target_language_name}) - {get_translation("traduction_terminee")} ; {get_translation("synthese_vocale_en_cours")}', state="running", expanded=False)
|
| 633 |
tts_audio, tts_duration = process_tts_message(st.session_state.full_response)
|
| 634 |
+
del st.session_state.full_response
|
| 635 |
if tts_audio:
|
| 636 |
st.audio(tts_audio, format="audio/mp3", autoplay=False)
|
| 637 |
audio_list.append((tts_audio, tts_duration))
|
| 638 |
+
del tts_audio
|
| 639 |
+
del tts_duration
|
| 640 |
response_status.update(label=f'({target_language_name}) - {get_translation("traduction_terminee")} ; {get_translation("synthese_vocale_terminee")}', state="complete", expanded=False)
|
| 641 |
else:
|
| 642 |
response_status.update(label=f'({target_language_name}) - {get_translation("erreur_synthese_vocale")}', state="error", expanded=False)
|
|
|
|
| 673 |
key=f"download_button_{langues}_{timestamp}",
|
| 674 |
)
|
| 675 |
|
| 676 |
+
# ##
|
| 677 |
audio_status.update(label=f"{get_translation('concatenation_audio_terminee')}", state="complete", expanded=True)
|
| 678 |
except Exception as e:
|
| 679 |
st.error(f"{get_translation('erreur_concatenation_audio')} : {str(e)}")
|
| 680 |
+
|
| 681 |
+
# ##
|
| 682 |
audio_status.update(label=f"{get_translation('erreur_concatenation_audio')} : {str(e)}", state="error", expanded=True)
|
| 683 |
+
|
| 684 |
+
# check if `final_audio` var exists , if exists delete final_audio
|
| 685 |
+
if 'final_audio' in locals():
|
| 686 |
+
del final_audio
|
| 687 |
+
if 'del audio_list' in locals():
|
| 688 |
+
del audio_list
|
| 689 |
+
|
| 690 |
|
| 691 |
|
| 692 |
|
|
|
|
| 739 |
with st.chat_message("assistant", avatar="👻"):
|
| 740 |
message_placeholder = st.empty()
|
| 741 |
response_generator = process_message(
|
| 742 |
+
transcription, operation_prompt, st.session_state.enable_tts_for_input_from_audio_record,
|
| 743 |
+
system_prompt=system_prompt
|
| 744 |
)
|
| 745 |
+
del transcription
|
| 746 |
+
del operation_prompt
|
| 747 |
+
del system_prompt
|
| 748 |
for response_chunk in response_generator:
|
| 749 |
message_placeholder.markdown(response_chunk)
|
| 750 |
+
end_response = response_generator.close()
|
| 751 |
if st.session_state.full_response != "":
|
| 752 |
message_placeholder.markdown(st.session_state.full_response)
|
| 753 |
|