gorkemgoknar commited on
Commit
03058be
·
1 Parent(s): 282f76d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -6,6 +6,7 @@ from transformers import GPT2Tokenizer, GPT2LMHeadModel
6
  from itertools import chain
7
 
8
  import os
 
9
 
10
  import tempfile
11
  from typing import Optional
@@ -57,7 +58,11 @@ def stt_record(audio_record_buffer):
57
  acoustic_model = Model(hf_hub_download(repo_id = REPO_ID, filename = "english/model.tflite"))
58
  scorer_path = hf_hub_download(repo_id = REPO_ID, filename = "english/huge-vocabulary.scorer")
59
 
60
- _, y = reformat_freq(*audio_record_buffer)
 
 
 
 
61
  scorer = True # use scorer
62
  if scorer:
63
  acoustic_model.enableExternalScorer(scorer_path)
@@ -288,7 +293,7 @@ history = {"character": "None", "message_history" : [] }
288
 
289
  interface_full = gr.Interface(fn=greet_stt_to_tts,
290
  inputs=[gr.Dropdown(personality_choices),
291
- gr.Audio(source="microphone", type="numpy", label="Record Audio") ,
292
  "state"],
293
  outputs=["html","state",gr.Audio(type="filepath")],
294
  css=css, title="Chat with Your Voice", description=description,article=article ,
 
6
  from itertools import chain
7
 
8
  import os
9
+ import librosa
10
 
11
  import tempfile
12
  from typing import Optional
 
58
  acoustic_model = Model(hf_hub_download(repo_id = REPO_ID, filename = "english/model.tflite"))
59
  scorer_path = hf_hub_download(repo_id = REPO_ID, filename = "english/huge-vocabulary.scorer")
60
 
61
+ if type(audio_record_buffer)!=tuple:
62
+ y, sr = librosa.load(audio_record_buffer)
63
+ _, y = reformat_freq(sr,y)
64
+ else:
65
+ _, y = reformat_freq(*audio_record_buffer)
66
  scorer = True # use scorer
67
  if scorer:
68
  acoustic_model.enableExternalScorer(scorer_path)
 
293
 
294
  interface_full = gr.Interface(fn=greet_stt_to_tts,
295
  inputs=[gr.Dropdown(personality_choices),
296
+ gr.Audio(source="microphone", type="filepath", label="Record Audio") ,
297
  "state"],
298
  outputs=["html","state",gr.Audio(type="filepath")],
299
  css=css, title="Chat with Your Voice", description=description,article=article ,