Nathan Franklin commited on
Commit
82f0eab
·
1 Parent(s): 3b38860

add capability to specify language in audio transcription step

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -10,12 +10,22 @@ def generate_response(correction_intensity,
10
  user_query_audio
11
  ):
12
  # Convert input audio to text
 
 
 
 
 
 
 
 
 
 
 
13
  # Ask llm for response to text
14
  # Convert llm response to audio
15
  # Return converted llm response
16
- user_query_transcribed_segments, info = model.transcribe(user_query_audio)
17
- user_query_transcribed = list(user_query_transcribed_segments)[0].text.strip()
18
- return user_query_audio, user_query_transcribed
19
 
20
  demo = gr.Interface(
21
  fn=generate_response,
@@ -41,7 +51,6 @@ demo = gr.Interface(
41
  type='filepath'
42
  )],
43
  outputs=[
44
- gr.Audio(label='User Query'),
45
  gr.Textbox(label='AI Buddy Response')
46
  ],
47
  title="AI Language Buddy"
 
10
  user_query_audio
11
  ):
12
  # Convert input audio to text
13
+
14
+ language_codes = {'English':'en',
15
+ 'Urdu':'ur',
16
+ 'Japanese':'ja'}
17
+
18
+ user_query_transcribed_segments, info = model.transcribe(
19
+ audio=user_query_audio,
20
+ language=language_codes[language_choice]
21
+ )
22
+ user_query_transcribed = list(user_query_transcribed_segments)[0].text.strip()
23
+
24
  # Ask llm for response to text
25
  # Convert llm response to audio
26
  # Return converted llm response
27
+
28
+ return user_query_transcribed
 
29
 
30
  demo = gr.Interface(
31
  fn=generate_response,
 
51
  type='filepath'
52
  )],
53
  outputs=[
 
54
  gr.Textbox(label='AI Buddy Response')
55
  ],
56
  title="AI Language Buddy"