Created
March 27, 2018 19:57
-
-
Save magnific0/048e2bbbbf8c858331e1aa68e101fbe8 to your computer and use it in GitHub Desktop.
[Guide] Trigger word - Try your own example!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the filename | |
your_filename = "audio_examples/1040676.wav" | |
clip = AudioSegment.from_mp3("audio_examples/1040676.mp3") | |
# Add whitenoise to end of shorter samples | |
from pydub.generators import WhiteNoise | |
noise_bg = WhiteNoise().to_audio_segment(duration=clip.duration_seconds*1000.0, volume=-50) | |
noise_end = WhiteNoise().to_audio_segment(duration=max(10000.0-clip.duration_seconds*1000.0,0), volume=-50) | |
clip = clip.overlay(noise_bg) + noise_end | |
# Convert to wav | |
clip.export(your_filename, format="wav") | |
# Predict | |
preprocess_audio(your_filename) | |
chime_threshold = 0.8 | |
prediction = detect_triggerword(your_filename) | |
chime_on_activate(your_filename, prediction, chime_threshold) | |
IPython.display.Audio("./chime_output.wav") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment