Isidorophp commited on
Commit
3515435
·
verified ·
1 Parent(s): 6842122

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -24
app.py CHANGED
@@ -14,7 +14,7 @@ import re
14
  import time
15
  from streaming_stt_nemo import Model
16
 
17
- number_to_word = inflect.engine()
18
 
19
  default_lang = "en"
20
 
@@ -51,24 +51,24 @@ def model(text):
51
 
52
  return output
53
 
54
- def number_to_words(str):
55
- words = str.split(' ')
56
- result = []
57
-
58
- for word in words:
59
- if( any(char.isdigit() for char in word) ):
60
- word = number_to_word.number_to_words(word)
61
-
62
- result.append(word)
63
-
64
- final_result = ' '.join(result).replace('point', '')
65
- return final_result
66
 
67
  async def respond(audio):
68
  user = transcribe(audio)
69
  reply = model(user)
70
- reply2 = number_to_words(reply)
71
-
72
  voices = await VoicesManager.create()
73
  voice = voices.find(Gender="Male", Locale="en-GB")
74
 
@@ -119,16 +119,18 @@ with gr.Blocks(css="style.css") as demo:
119
  ### <center>Now Talk to - Dr. Watson</center>
120
  """)
121
  with gr.Row():
122
- user_input = gr.Audio( label="Your Voice Chat", type="filepath", interactive=True, elem_classes="microphone" )
123
- output_audio = gr.Audio( label="WATSON", type="filepath", interactive=False, elem_classes="audio", autoplay=True )
124
- with gr.Row():
125
- translate_btn = gr.Button("Response")
126
- translate_btn.click( fn=respond, inputs=user_input, outputs=output_audio, api_name=False )
 
 
127
 
128
  with gr.Row():
129
- user_input = gr.Textbox( label="Your Question", value="Dr. Watson can you summarize your adventures with Sherlock Holmes?")
130
- input_text = gr.Textbox( label="Input Text", elem_id="important")
131
- output_audio = gr.Audio( label="WATSON", type="filepath", interactive=False, elem_classes="audio", autoplay=True )
132
  with gr.Row():
133
  translate_btn = gr.Button("Response")
134
  translate_btn.click(fn=generate1, inputs=user_input, outputs=output_audio, api_name="translate")
@@ -136,6 +138,6 @@ with gr.Blocks(css="style.css") as demo:
136
 
137
 
138
  if __name__ == "__main__":
139
- demo.queue(max_size=200,api_open=False).launch()
140
 
141
 
 
14
  import time
15
  from streaming_stt_nemo import Model
16
 
17
+ # number_to_word = inflect.engine()
18
 
19
  default_lang = "en"
20
 
 
51
 
52
  return output
53
 
54
+ #def number_to_words(str):
55
+ # words = str.split(' ')
56
+ # result = []
57
+ #
58
+ # for word in words:
59
+ # if( any(char.isdigit() for char in word) ):
60
+ # word = number_to_word.number_to_words(word)
61
+ #
62
+ # result.append(word)
63
+ #
64
+ # final_result = ' '.join(result).replace('point', '')
65
+ # return final_result
66
 
67
  async def respond(audio):
68
  user = transcribe(audio)
69
  reply = model(user)
70
+ # reply2 = number_to_words(reply)
71
+ #
72
  voices = await VoicesManager.create()
73
  voice = voices.find(Gender="Male", Locale="en-GB")
74
 
 
119
  ### <center>Now Talk to - Dr. Watson</center>
120
  """)
121
  with gr.Row():
122
+ input = gr.Audio(label="Your Voice Chat", type="filepath", interactive=True, sources="microphone", waveform_options=False)
123
+ output = gr.Audio(label="WATSON", type="filepath", interactive=False, autoplay=True, elem_classes="audio")
124
+ gr.Interface(fn=respond, Inputs=[input], outputs=[output], live=True)
125
+
126
+ #with gr.Row():
127
+ # translate_btn = gr.Button("Response")
128
+ # translate_btn.click( fn=respond, inputs=user_input, outputs=output_audio, api_name=False )
129
 
130
  with gr.Row():
131
+ user_input = gr.Textbox(label="Your Question", value="Dr. Watson can you summarize your adventures with Sherlock Holmes?")
132
+ input_text = gr.Textbox(label="Input Text", elem_id="important")
133
+ output_audio = gr.Audio(label="WATSON", type="filepath", interactive=False, autoplay=True, elem_classes="audio")
134
  with gr.Row():
135
  translate_btn = gr.Button("Response")
136
  translate_btn.click(fn=generate1, inputs=user_input, outputs=output_audio, api_name="translate")
 
138
 
139
 
140
  if __name__ == "__main__":
141
+ demo.queue(max_size=200, api_open=False).launch()
142
 
143