Kevin676 commited on
Commit
8afab49
1 Parent(s): 957670c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -20,7 +20,7 @@ pipeline = PIPELINE(model, "20B_tokenizer.json")
20
  from TTS.api import TTS
21
  tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=True)
22
  import whisper
23
- model = whisper.load_model("small")
24
 
25
  os.system('pip install voicefixer --upgrade')
26
  from voicefixer import VoiceFixer
@@ -66,16 +66,16 @@ def evaluate(
66
  audio = whisper.load_audio(audio)
67
  audio = whisper.pad_or_trim(audio)
68
 
69
- # make log-Mel spectrogram and move to the same device as the model
70
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
71
 
72
  # detect the spoken language
73
- _, probs = model.detect_language(mel)
74
  print(f"Detected language: {max(probs, key=probs.get)}")
75
 
76
  # decode the audio
77
  options = whisper.DecodingOptions()
78
- result = whisper.decode(model, mel, options)
79
 
80
 
81
  res = []
@@ -122,9 +122,9 @@ def evaluate(
122
 
123
  res.append(out_str.strip())
124
 
125
- res1 = ''.join(str(x) for x in res)
126
 
127
- tts.tts_to_file(res1, speaker_wav = upload, language="en", file_path="output.wav")
128
 
129
  voicefixer.restore(input="output.wav", # input wav file path
130
  output="audio1.wav", # output wav file path
 
20
  from TTS.api import TTS
21
  tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=True)
22
  import whisper
23
+ model1 = whisper.load_model("small")
24
 
25
  os.system('pip install voicefixer --upgrade')
26
  from voicefixer import VoiceFixer
 
66
  audio = whisper.load_audio(audio)
67
  audio = whisper.pad_or_trim(audio)
68
 
69
+ # make log-Mel spectrogram and move to the same device as the model1
70
+ mel = whisper.log_mel_spectrogram(audio).to(model1.device)
71
 
72
  # detect the spoken language
73
+ _, probs = model1.detect_language(mel)
74
  print(f"Detected language: {max(probs, key=probs.get)}")
75
 
76
  # decode the audio
77
  options = whisper.DecodingOptions()
78
+ result = whisper.decode(model1, mel, options)
79
 
80
 
81
  res = []
 
122
 
123
  res.append(out_str.strip())
124
 
125
+ # res1 = ''.join(str(x) for x in res)
126
 
127
+ tts.tts_to_file(res, speaker_wav = upload, language="en", file_path="output.wav")
128
 
129
  voicefixer.restore(input="output.wav", # input wav file path
130
  output="audio1.wav", # output wav file path