Spaces:
Runtime error
Runtime error
Tidy
Browse files28 unmodified lines2930313233343536102 unmodified lines1391401411421431448 unmodified lines15315415515615715815916016116216312 unmodified lines176177178179180181182183184185186187188326 unmodified lines5155165175185195205215225235247 unmodified lines5325335345355365375385395405415425435445455465477 unmodified lines5555565575585595605617 unmodified lines56957057157257328 unmodified linesimage_description = ""# audio_output = ""global markdown_outputglobal audio_outputdef check_hallucination(assertion, citation):102 unmodified linesexcept Exception as e:return f"{e}"def convert_text_to_speech(input_text: str, source_language: str, target_language: str) -> tuple[str, str]:client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")8 unmodified linestarget_language,api_name="/run",)# Check if the result is validif not result:raise ValueError("No result returned from text-to-speech service")# Initialize variablestranslated_text = ""audio_file_path = ""12 unmodified linesaudio_file_path = save_audio(item) # Save the audio filebreakif not audio_file_path:raise ValueError("No audio file path returned from text-to-speech service")return audio_file_path, translated_textexcept Exception as e:return "", f"Error in text-to-speech conversion: {str(e)}"def process_image(image_input):# Initialize the Gradio client with the URL of the Gradio server326 unmodified lines"Vietnamese": "vie"}def clear():# Return default values for each componentreturn "English", None, None, "", Nonedef create_interface():# with gr.Blocks(theme='ParityError/Anime') as iface:with gr.Blocks(theme='ParityError/Anime') as interface:7 unmodified lines# Create a dropdown for language selectioninput_language = gr.Dropdown(input_language_options, label="Select the language", value="English", interactive=True)with gr.Accordion("Use Voice", open=False) as voice_accordion:audio_input = gr.Audio(label="Speak")audio_output = gr.Markdown(label="Output text") # Markdown component for audiogr.Examples([["audio1.wav"],["audio2.wav"],],inputs=[audio_input])with gr.Accordion("Use a Picture", open=False) as picture_accordion:image_input = gr.Image(label="Upload image")image_output = gr.Markdown(label="Output text") # Markdown component for imagegr.Examples([["image1.png"], ["image2.jpeg"], ["image3.jpeg"],],inputs=[image_input])with gr.Accordion("MultiMed", open=False) as multimend_accordion:text_input = gr.Textbox(label="Use Text", lines=3, placeholder="I have had a sore throat and phlegm for a few days and now my cough has gotten worse!")7 unmodified lines["بکل ہرپس کا صحیح علاج کیا ہے؟"],["구강 헤르페스의 적절한 치료법은 무엇입니까?"],["Je, ni matibabu gani sahihi kwa herpes ya buccal?"],],inputs=[text_input])text_output = gr.Markdown(label="MultiMed")audio_output = gr.Audio(label="Audio Out", type="filepath")7 unmodified linesreturn interfaceinterface = create_interface()interface.launch(show_error=True, debug=True)28 unmodified lines2930313233343536102 unmodified lines1391401411421431441458 unmodified lines15415515615715815916012 unmodified lines173174175176177178179180181182183326 unmodified lines5105115125135145155165175185195205217 unmodified lines5295305315325335345355365375385395405415425435447 unmodified lines5525535545555565575587 unmodified lines56656756856957028 unmodified linesimage_description = ""# audio_output = ""# global markdown_output# global audio_outputdef check_hallucination(assertion, citation):102 unmodified linesexcept Exception as e:return f"{e}"def convert_text_to_speech(input_text: str, source_language: str, target_language: str) -> tuple[str, str]:client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")8 unmodified linestarget_language,api_name="/run",)# Initialize variablestranslated_text = ""audio_file_path = ""12 unmodified linesaudio_file_path = save_audio(item) # Save the audio filebreakreturn audio_file_path, translated_textexcept Exception as e:return f"Error in text-to-speech conversion: {str(e)}", ""def process_image(image_input):# Initialize the Gradio client with the URL of the Gradio server326 unmodified lines"Vietnamese": "vie"}def clear():# Return default values for each componentreturn "English", None, None, "", Nonedef create_interface():# with gr.Blocks(theme='ParityError/Anime') as iface:with gr.Blocks(theme='ParityError/Anime') as interface:7 unmodified lines# Create a dropdown for language selectioninput_language = gr.Dropdown(input_language_options, label="Select the language", value="English", interactive=True)with gr.Accordion("Use Voice", open=False) as voice_accordion:audio_input = gr.Audio(label="Speak")audio_output = gr.Markdown(label="Output text") # Markdown component for audiogr.Examples([["audio1.wav"], ["audio2.wav"], ], inputs=[audio_input])with gr.Accordion("Use a Picture", open=False) as picture_accordion:image_input = gr.Image(label="Upload image")image_output = gr.Markdown(label="Output text") # Markdown component for imagegr.Examples([["image1.png"], ["image2.jpeg"], ["image3.jpeg"], ], inputs=[image_input])with gr.Accordion("MultiMed", open=False) as multimend_accordion:text_input = gr.Textbox(label="Use Text", lines=3, placeholder="I have had a sore throat and phlegm for a few days and now my cough has gotten worse!")7 unmodified lines["بکل ہرپس کا صحیح علاج کیا ہے؟"],["구강 헤르페스의 적절한 치료법은 무엇입니까?"],["Je, ni matibabu gani sahihi kwa herpes ya buccal?"],], inputs=[text_input])text_output = gr.Markdown(label="MultiMed")audio_output = gr.Audio(label="Audio Out", type="filepath")7 unmodified linesreturn interfaceapp = create_interface()app.launch(show_error=True, debug=True)
app.py+14-17