Skip to content

Instantly share code, notes, and snippets.

@fauxneticien
Created October 19, 2023 04:33
Show Gist options
  • Save fauxneticien/34d0bfc675d40207c39f7d9412d7543f to your computer and use it in GitHub Desktop.
Save fauxneticien/34d0bfc675d40207c39f7d9412d7543f to your computer and use it in GitHub Desktop.
A solution for Colab exercise
def signal2int(signal, sample_rate=16_000, seq_length=4):
"""
Decode a sine wave signal back into digits
"""
digits = []
for start_index in range(0, sample_rate * seq_length, sample_rate):
end_index = start_index + sample_rate - 1
window_samples = signal[start_index:end_index]
window_pitch = extract_pitch(window_samples)
window_digit = int(window_pitch/100 - 1)
digits.append(window_digit)
return digits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment