ysharma HF staff commited on
Commit
c72df7c
1 Parent(s): 2915c8f

updates for other languages

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -120,6 +120,7 @@ def lang_model_response(prompt, language):
120
  prompt = p_es + prompt + "\n" + "Responder: "
121
  elif language == 'fr':
122
  prompt = p_fr + prompt + "\n" + "Réponse: "
 
123
 
124
  json_ = {"inputs": prompt,
125
  "parameters":
@@ -145,6 +146,16 @@ def lang_model_response(prompt, language):
145
  solution = output_tmp.split("Responder: ")[2].split("\n")[0]
146
  elif language == 'fr':
147
  solution = output_tmp.split("Réponse: ")[2].split("\n")[0]
 
 
 
 
 
 
 
 
 
 
148
  # solution = output_tmp.split(".")[1]
149
  print(f"Final Bloom Response after splits is: {solution}")
150
  return solution
@@ -172,7 +183,7 @@ with demo:
172
  out_transcript = gr.Textbox(label= 'English/Spanish/French Transcript of your Audio using OpenAI Whisper')
173
  out_translation_en = gr.Textbox(label= 'English Translation of audio using OpenAI Whisper')
174
  with gr.Column():
175
- out_audio = gr.Audio(label='AI response in Audio form in your preferred language')
176
  out_generated_text = gr.Textbox(label= 'AI response to your query in your preferred language using Bloom! ')
177
  out_generated_text_en = gr.Textbox(label= 'AI response to your query in English using Bloom! ')
178
 
 
120
  prompt = p_es + prompt + "\n" + "Responder: "
121
  elif language == 'fr':
122
  prompt = p_fr + prompt + "\n" + "Réponse: "
123
+ #else:
124
 
125
  json_ = {"inputs": prompt,
126
  "parameters":
 
146
  solution = output_tmp.split("Responder: ")[2].split("\n")[0]
147
  elif language == 'fr':
148
  solution = output_tmp.split("Réponse: ")[2].split("\n")[0]
149
+ else:
150
+ if '?' in output_tmp:
151
+ solution = output_tmp.split("?")[1]
152
+ elif '.' in output_tmp:
153
+ solution = output_tmp.split(".")[1]
154
+ elif ',' in output_tmp:
155
+ solution = output_tmp.split(",")[1]
156
+ else:
157
+ solution = output_tmp[:25]
158
+ print(f"Another language was used : {language}")
159
  # solution = output_tmp.split(".")[1]
160
  print(f"Final Bloom Response after splits is: {solution}")
161
  return solution
 
183
  out_transcript = gr.Textbox(label= 'English/Spanish/French Transcript of your Audio using OpenAI Whisper')
184
  out_translation_en = gr.Textbox(label= 'English Translation of audio using OpenAI Whisper')
185
  with gr.Column():
186
+ out_audio = gr.Audio(label='AI response in Audio form in your language - This will be either in Spanish, or in French or in English for all other languages -')
187
  out_generated_text = gr.Textbox(label= 'AI response to your query in your preferred language using Bloom! ')
188
  out_generated_text_en = gr.Textbox(label= 'AI response to your query in English using Bloom! ')
189