Skip to content

Commit 301b97f

Browse files
committed
remove noncolab support.
1 parent 13452b8 commit 301b97f

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

intermediate_source/speech_command_recognition_with_torchaudio_tutorial.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -524,35 +524,11 @@ def record(seconds=1):
524524
return torchaudio.load(filename)
525525

526526

527-
def record_noncolab(seconds=1):
528-
529-
import sounddevice
530-
import scipy.io.wavfile
531-
532-
sample_rate = 44100
533-
534-
print(f"Recording started for {seconds} seconds.")
535-
myrecording = sounddevice.rec(
536-
int(seconds * sample_rate), samplerate=sample_rate, channels=1
537-
)
538-
sounddevice.wait()
539-
print("Recording ended.")
540-
541-
filename = "_audio.wav"
542-
scipy.io.wavfile.write(filename, sample_rate, myrecording)
543-
return torchaudio.load(filename)
544-
545-
546527
# Detect whether notebook runs in google colab
547528
if "google.colab" in sys.modules:
548-
record = record_colab
549-
else:
550-
record = record_noncolab
551-
552-
553-
waveform, sample_rate = record()
554-
print(f"Predicted: {predict(waveform)}.")
555-
ipd.Audio(waveform.numpy(), rate=sample_rate)
529+
waveform, sample_rate = record()
530+
print(f"Predicted: {predict(waveform)}.")
531+
ipd.Audio(waveform.numpy(), rate=sample_rate)
556532

557533

558534
######################################################################

0 commit comments

Comments
 (0)