XDHDD commited on
Commit
3ed90c0
1 Parent(s): 4a2e676

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -310,7 +310,7 @@ if st.button('Сгенерировать потери'):
310
 
311
 
312
 
313
- #harvard = speech_r.AudioFile('lossy.wav')
314
  #with harvard as source:
315
  # audio = r.record(source)
316
  #lossy = r.recognize_google(audio, language = "ru-RU")
@@ -321,20 +321,36 @@ if st.button('Сгенерировать потери'):
321
  lossy = r.recognize_google(audio, language = "ru-RU")
322
  #print("Распознанный текст:", text)
323
  except speech_r.UnknownValueError:
324
- print("Система не смогла распознать аудио")
325
  lossy = ''
326
  except speech_r.RequestError as e:
327
- print("Ошибка при запросе к сервису распознавания речи; {0}".format(e))
328
 
329
 
330
 
331
 
332
 
333
  harvard = speech_r.AudioFile('enhanced.wav')
334
- with harvard as source:
335
- audio = r.record(source)
336
- enhanced = r.recognize_google(audio, language = "ru-RU")
 
 
 
 
 
 
 
 
 
 
 
 
337
 
 
 
 
 
338
  error1 = wer(orig, orig)
339
  error2 = wer(orig, lossy)
340
  error3 = wer(orig, enhanced)
 
310
 
311
 
312
 
313
+ harvard = speech_r.AudioFile('lossy.wav')
314
  #with harvard as source:
315
  # audio = r.record(source)
316
  #lossy = r.recognize_google(audio, language = "ru-RU")
 
321
  lossy = r.recognize_google(audio, language = "ru-RU")
322
  #print("Распознанный текст:", text)
323
  except speech_r.UnknownValueError:
324
+ st.text("Система не смогла распознать аудио")
325
  lossy = ''
326
  except speech_r.RequestError as e:
327
+ st.text("Ошибка при запросе к сервису распознавания речи; {0}".format(e))
328
 
329
 
330
 
331
 
332
 
333
  harvard = speech_r.AudioFile('enhanced.wav')
334
+ #with harvard as source:
335
+ # audio = r.record(source)
336
+ #enhanced = r.recognize_google(audio, language = "ru-RU")
337
+
338
+ try:
339
+ with harvard as source:
340
+ audio = r.record(source)
341
+ enhanced = r.recognize_google(audio, language = "ru-RU")
342
+ #print("Распознанный текст:", text)
343
+ except speech_r.UnknownValueError:
344
+ st.text("Система не смогла распознать улучшенное аудио")
345
+ enhanced = ''
346
+ except speech_r.RequestError as e:
347
+ st.text("Ошибка при запросе к сервису распознавания речи; {0}".format(e))
348
+
349
 
350
+
351
+
352
+
353
+
354
  error1 = wer(orig, orig)
355
  error2 = wer(orig, lossy)
356
  error3 = wer(orig, enhanced)