Tonic commited on
Commit
583b605
1 Parent(s): 19429d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -105
app.py CHANGED
@@ -377,6 +377,12 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
377
  combined_text = ""
378
  markdown_output = ""
379
  image_text = ""
 
 
 
 
 
 
380
 
381
  # Debugging print statement
382
  print(f"Image Input Type: {type(image_input)}, Audio Input Type: {type(audio_input)}")
@@ -427,8 +433,8 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
427
 
428
  # Convert translated text to speech and get both audio file and text
429
  target_language = "English" # Set the target language for the speech
430
- audio_output, translated_text = convert_text_to_speech(final_response, target_language, input_language)
431
-
432
  # Evaluate hallucination
433
  hallucination_label = evaluate_hallucination(final_response, summary)
434
 
@@ -464,108 +470,42 @@ do [get in touch](https://discord.gg/GWpVpekp). You can also use 😷MultiMed⚕
464
 
465
 
466
  languages = [
467
- "Afrikaans",
468
- "Amharic",
469
- "Modern Standard Arabic",
470
- "Moroccan Arabic",
471
- "Egyptian Arabic",
472
- "Assamese",
473
- "Asturian",
474
- "North Azerbaijani",
475
- "Belarusian",
476
- "Bengali",
477
- "Bosnian",
478
- "Bulgarian",
479
- "Catalan",
480
- "Cebuano",
481
- "Czech",
482
- "Central Kurdish",
483
- "Mandarin Chinese",
484
- "Welsh",
485
- "Danish",
486
- "German",
487
- "Greek",
488
- "English",
489
- "Estonian",
490
- "Basque",
491
- "Finnish",
492
- "French",
493
- "West Central Oromo",
494
- "Irish",
495
- "Galician",
496
- "Gujarati",
497
- "Hebrew",
498
- "Hindi",
499
- "Croatian",
500
- "Hungarian",
501
- "Armenian",
502
- "Igbo",
503
- "Indonesian",
504
- "Icelandic",
505
- "Italian",
506
- "Javanese",
507
- "Japanese",
508
- "Kamba",
509
- "Kannada",
510
- "Georgian",
511
- "Kazakh",
512
- "Kabuverdianu",
513
- "Halh Mongolian",
514
- "Khmer",
515
- "Kyrgyz",
516
- "Korean",
517
- "Lao",
518
- "Lithuanian",
519
- "Luxembourgish",
520
- "Ganda",
521
- "Luo",
522
- "Standard Latvian",
523
- "Maithili",
524
- "Malayalam",
525
- "Marathi",
526
- "Macedonian",
527
- "Maltese",
528
- "Meitei",
529
- "Burmese",
530
- "Dutch",
531
- "Norwegian Nynorsk",
532
- "Norwegian Bokmål",
533
- "Nepali",
534
- "Nyanja",
535
- "Occitan",
536
- "Odia",
537
- "Punjabi",
538
- "Southern Pashto",
539
- "Western Persian",
540
- "Polish",
541
- "Portuguese",
542
- "Romanian",
543
- "Russian",
544
- "Slovak",
545
- "Slovenian",
546
- "Shona",
547
- "Sindhi",
548
- "Somali",
549
- "Spanish",
550
- "Serbian",
551
- "Swedish",
552
- "Swahili",
553
- "Tamil",
554
- "Telugu",
555
- "Tajik",
556
- "Tagalog",
557
- "Thai",
558
- "Turkish",
559
- "Ukrainian",
560
- "Urdu",
561
- "Northern Uzbek",
562
- "Vietnamese",
563
- "Xhosa",
564
- "Yoruba",
565
- "Cantonese",
566
- "Colloquial Malay",
567
- "Standard Malay",
568
- "Zulu"
569
  ]
570
 
571
  def clear():
@@ -577,8 +517,13 @@ def create_interface():
577
  with gr.Blocks(theme='ParityError/Anime') as interface:
578
  # Display the welcome message
579
  gr.Markdown(welcome_message)
 
 
 
580
  # Add a 'None' or similar option to represent no selection
581
- input_language_options = ["None"] + languages
 
 
582
  input_language = gr.Dropdown(input_language_options, label="Select the language", value="English", interactive=True)
583
 
584
  with gr.Accordion("Use Voice", open=False) as voice_accordion:
 
377
  combined_text = ""
378
  markdown_output = ""
379
  image_text = ""
380
+ # Initialize language code
381
+ language_code = None
382
+
383
+ # Convert input language to its code
384
+ if input_language and input_language in languages:
385
+ language_code = languages[input_language]
386
 
387
  # Debugging print statement
388
  print(f"Image Input Type: {type(image_input)}, Audio Input Type: {type(audio_input)}")
 
433
 
434
  # Convert translated text to speech and get both audio file and text
435
  target_language = "English" # Set the target language for the speech
436
+ audio_output, translated_text = convert_text_to_speech(final_response, target_language, language_code)
437
+
438
  # Evaluate hallucination
439
  hallucination_label = evaluate_hallucination(final_response, summary)
440
 
 
470
 
471
 
472
  languages = [
473
+ "English" : "eng",
474
+ "Modern Standard Arabic" : "arb",
475
+ "Bengali" : "ben",
476
+ "Catalan" : "cat",
477
+ "Czech" : "ces",
478
+ "Mandarin Chinese" : "cmn",
479
+ "Welsh" : "cym",
480
+ "Danish" : "dan",
481
+ "German" : "deu",
482
+ "Estonian" : "est",
483
+ "Finnish" : "fin",
484
+ "French" : "fra",
485
+ "Hindi" : "hin",
486
+ "Indonesian" : "ind",
487
+ "Italian" : "ita",
488
+ "Japanese" : "jpn",
489
+ "Korean" : "kor",
490
+ "Maltese" : "mlt",
491
+ "Dutch" : "nld",
492
+ "Western Persian" : "pes",
493
+ "Polish" : "pol",
494
+ "Portuguese" : "por",
495
+ "Romanian" : "ron",
496
+ "Russian" : "rus",
497
+ "Slovak" : "slk",
498
+ "Spanish" : "spa",
499
+ "Swedish" : "swe",
500
+ "Swahili" : "swh",
501
+ "Telugu" : "tel",
502
+ "Tagalog" : "tgl",
503
+ "Thai" : "tha",
504
+ "Turkish" : "tur",
505
+ "Ukrainian" : "ukr",
506
+ "Urdu" : "urd",
507
+ "Northern Uzbek" : "uzn",
508
+ "Vietnamese" : "vie"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  ]
510
 
511
  def clear():
 
517
  with gr.Blocks(theme='ParityError/Anime') as interface:
518
  # Display the welcome message
519
  gr.Markdown(welcome_message)
520
+ # Extract the full names of the languages
521
+ language_names = list(languages.keys())
522
+
523
  # Add a 'None' or similar option to represent no selection
524
+ input_language_options = ["None"] + language_names
525
+
526
+ # Create a dropdown for language selection
527
  input_language = gr.Dropdown(input_language_options, label="Select the language", value="English", interactive=True)
528
 
529
  with gr.Accordion("Use Voice", open=False) as voice_accordion: