From b03027218cf4df0c6330461c4066753df7a9cac9 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Sat, 27 Apr 2024 16:01:09 -0500 Subject: [PATCH] Test file --- play-test.py | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 play-test.py diff --git a/play-test.py b/play-test.py deleted file mode 100644 index 34c5d69..0000000 --- a/play-test.py +++ /dev/null @@ -1,33 +0,0 @@ -"""PyAudio Example: Play a wave file.""" - -import wave -import sys - -import pyaudio - - -CHUNK = 1024 - -if len(sys.argv) < 2: - print(f'Plays a wave file. Usage: {sys.argv[0]} filename.wav') - sys.exit(-1) - -with wave.open(sys.argv[1], 'rb') as wf: - # Instantiate PyAudio and initialize PortAudio system resources (1) - p = pyaudio.PyAudio() - - # Open stream (2) - stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), - channels=wf.getnchannels(), - rate=wf.getframerate(), - output=True) - - # Play samples from the wave file (3) - while len(data := wf.readframes(CHUNK)): # Requires Python 3.8+ for := - stream.write(data) - - # Close stream (4) - stream.close() - - # Release PortAudio system resources (5) - p.terminate()