We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45169f8 commit acabf69Copy full SHA for acabf69
examples/play_file.py
@@ -5,18 +5,17 @@
5
6
"""
7
import argparse
8
-import sounddevice as sd
9
-import soundfile as sf
10
-import sys
11
12
parser = argparse.ArgumentParser(description=__doc__)
13
parser.add_argument("filename", help="audio file to be played back")
14
parser.add_argument("-d", "--device", type=int, help="device ID")
15
args = parser.parse_args()
16
17
try:
+ import sounddevice as sd
+ import soundfile as sf
18
data, fs = sf.read(args.filename, dtype='float32')
19
sd.play(data, fs, device=args.device, blocking=True)
20
-except:
+except BaseException as e:
21
# This avoids printing the traceback, especially if Ctrl-C is used.
22
- sys.exit(sys.exc_info()[1])
+ raise SystemExit(str(e))
0 commit comments