Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix audio inference - Pass --level 0 to audio feature extractor, and improve error handling #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/demo/multimodial_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ def audio_inference(clip: str, coeffs: list):
subprocess.run(['ffmpeg', '-i', clip, '-map', '0:a', '-y', out_audio],
capture_output=True)
time.sleep(1)
if osp.exists(out_audio):
verbose_print(f'Generated WAV for clip {clip}', style='yellow')
else:
verbose_print(f'FAILED to generate WAV for some reason for clip {clip}', style='yellow')
PREDS[clip]['audio'] = placeholder
return

data, rate = sf.read(out_audio)
meter = pyln.Meter(rate) # meter works with decibels
Expand All @@ -378,9 +384,15 @@ def audio_inference(clip: str, coeffs: list):
return

out_feature = f'{osp.splitext(out_audio)[0]}.npy'
subprocess.run(
['python', AUDIO_FEATURE_SCRIPT, TEMP, TEMP, '--ext', 'wav'],
exec_result = subprocess.run(
['python', AUDIO_FEATURE_SCRIPT, TEMP, TEMP, '--ext', 'wav', '--level', '0'],
capture_output=True)
if osp.exists(out_feature):
verbose_print(f'Generated audio feature for clip {clip}', style='yellow')
else:
verbose_print(f'FAILED to generate feature file for some reason for clip {clip}', style='yellow')
PREDS[clip]['audio'] = placeholder
return

results = inference_recognizer(AUDIO_MODEL, out_feature)
results = [(AUDIO_LABELS[k[0]], k[1]) for k in results]
Expand Down