Spaces:
Runtime error
Runtime error
Update app.py
Browse files1234511 unmodified lines171819202122153 unmodified lines176177178179180181182196 unmodified lines37938038138238338438548 unmodified lines43443543643743843944013 unmodified lines454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516# Welcome to Team Tonic's MultiMedfrom gradio_client import Clientimport numpy as npimport gradio as gr11 unmodified linesimport uuid# Global variables to hold component referencescomponents = {}dotenv.load_dotenv()153 unmodified linesreturn audio_file_path, translated_textexcept Exception as e:return f"Error in text-to-speech conversion: {str(e)}", ""def process_image(image_input):196 unmodified linescombined_text = ""markdown_output = ""image_text = ""# Initialize language codelanguage_code = None# Convert input language to its code48 unmodified linesfinal_response = process_summary_with_stablemed(summary)# Convert translated text to speech and get both audio file and texttarget_language = "English" # Set the target language for the speechaudio_output, translated_text = convert_text_to_speech(final_response, target_language, language_code)# Evaluate hallucination13 unmodified linesreturn f"Error occurred during processing: {e}. No hallucination evaluation.", Nonewelcome_message = """# 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷🗣️📝 This is an educational and accessible conversational tool.### How To Use ⚕🗣️😷MultiMed⚕:🗣️📝Interact with ⚕🗣️😷MultiMed⚕ in any language using image, audio or text!📚🌟💼 that uses [Tonic/stablemed](https://huggingface.co/Tonic/stablemed) and [adept/fuyu-8B](https://huggingface.co/adept/fuyu-8b) with [Vectara](https://huggingface.co/vectara) embeddings + retrieval.do [get in touch](https://discord.gg/GWpVpekp). You can also use 😷MultiMed⚕️ on your own data & in your own way by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/TeamTonic/MultiMed?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>### Join us :🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)""""languages = {"English": "eng","Modern Standard Arabic": "arb","Bengali": "ben","Catalan": "cat","Czech": "ces","Mandarin Chinese": "cmn","Welsh": "cym","Danish": "dan","German": "deu","Estonian": "est","Finnish": "fin","French": "fra","Hindi": "hin","Indonesian": "ind","Italian": "ita","Japanese": "jpn","Korean": "kor","Maltese": "mlt","Dutch": "nld","Western Persian": "pes","Polish": "pol","Portuguese": "por","Romanian": "ron","Russian": "rus","Slovak": "slk","Spanish": "spa","Swedish": "swe","Swahili": "swh","Telugu": "tel","Tagalog": "tgl","Thai": "tha","Turkish": "tur","Ukrainian": "ukr","Urdu": "urd","Northern Uzbek": "uzn","Vietnamese": "vie"}def clear():# Return default values for each componentreturn "English", None, None, "", None12311 unmodified lines151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677153 unmodified lines231232233234235236237196 unmodified lines43443543643743843948 unmodified lines48848949049149249349413 unmodified lines508509510511512513from gradio_client import Clientimport numpy as npimport gradio as gr11 unmodified linesimport uuidwelcome_message = """# 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷🗣️📝 This is an educational and accessible conversational tool.### How To Use ⚕🗣️😷MultiMed⚕:🗣️📝Interact with ⚕🗣️😷MultiMed⚕ in any language using image, audio or text!📚🌟💼 that uses [Tonic/stablemed](https://huggingface.co/Tonic/stablemed) and [adept/fuyu-8B](https://huggingface.co/adept/fuyu-8b) with [Vectara](https://huggingface.co/vectara) embeddings + retrieval.do [get in touch](https://discord.gg/GWpVpekp). You can also use 😷MultiMed⚕️ on your own data & in your own way by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/TeamTonic/MultiMed?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>### Join us :🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)""""languages = {"English": "eng","Modern Standard Arabic": "arb","Bengali": "ben","Catalan": "cat","Czech": "ces","Mandarin Chinese": "cmn","Welsh": "cym","Danish": "dan","German": "deu","Estonian": "est","Finnish": "fin","French": "fra","Hindi": "hin","Indonesian": "ind","Italian": "ita","Japanese": "jpn","Korean": "kor","Maltese": "mlt","Dutch": "nld","Western Persian": "pes","Polish": "pol","Portuguese": "por","Romanian": "ron","Russian": "rus","Slovak": "slk","Spanish": "spa","Swedish": "swe","Swahili": "swh","Telugu": "tel","Tagalog": "tgl","Thai": "tha","Turkish": "tur","Ukrainian": "ukr","Urdu": "urd","Northern Uzbek": "uzn","Vietnamese": "vie"}# Global variables to hold component referencescomponents = {}dotenv.load_dotenv()153 unmodified linesreturn audio_file_path, translated_textexcept Exception as e:return None, f"Error in text-to-speech conversion: {str(e)}"def process_image(image_input):196 unmodified linescombined_text = ""markdown_output = ""image_text = ""language_code = None# Convert input language to its code48 unmodified linesfinal_response = process_summary_with_stablemed(summary)# Convert translated text to speech and get both audio file and texttarget_language = "eng" # Set the target language for the speechaudio_output, translated_text = convert_text_to_speech(final_response, target_language, language_code)# Evaluate hallucination13 unmodified linesreturn f"Error occurred during processing: {e}. No hallucination evaluation.", Nonedef clear():# Return default values for each componentreturn "English", None, None, "", None
app.py+59-62