Spaces:
Runtime error
Runtime error
Hendrik Schroeter
commited on
brute force codecs
Browse files
app.py
CHANGED
@@ -71,16 +71,19 @@ def mix_and_denoise(speech_rec, speech_upl, noise, snr):
|
|
71 |
speech_file = speech_rec
|
72 |
sp_kwargs = {"frame_offset": 4800}
|
73 |
meta = None
|
|
|
74 |
for f in ("wav", "mp3", "flac", "vorbis", "opus"):
|
75 |
-
print(f)
|
76 |
# Chrome saves files as opus now.
|
77 |
sp_kwargs["format"] = f
|
78 |
try:
|
79 |
speech, meta = load_audio(speech_file, sr, **sp_kwargs)
|
80 |
-
except RuntimeError
|
81 |
if meta is not None:
|
82 |
print(meta)
|
83 |
-
|
|
|
|
|
|
|
84 |
logger.info(f"Loaded speech with shape {speech.shape}")
|
85 |
noise, _ = load_audio(noise, sr)
|
86 |
if meta.sample_rate != sr:
|
|
|
71 |
speech_file = speech_rec
|
72 |
sp_kwargs = {"frame_offset": 4800}
|
73 |
meta = None
|
74 |
+
# Apperently chrome uses flac or opus?
|
75 |
for f in ("wav", "mp3", "flac", "vorbis", "opus"):
|
|
|
76 |
# Chrome saves files as opus now.
|
77 |
sp_kwargs["format"] = f
|
78 |
try:
|
79 |
speech, meta = load_audio(speech_file, sr, **sp_kwargs)
|
80 |
+
except RuntimeError:
|
81 |
if meta is not None:
|
82 |
print(meta)
|
83 |
+
break
|
84 |
+
if meta is None:
|
85 |
+
logger.error("Could not load recorded speech")
|
86 |
+
return(1)
|
87 |
logger.info(f"Loaded speech with shape {speech.shape}")
|
88 |
noise, _ = load_audio(noise, sr)
|
89 |
if meta.sample_rate != sr:
|