Skip to content

Commit 4af2c5f

Browse files
committed
fixed readme of record & play audio tutorial
1 parent 8f249e7 commit 4af2c5f

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

general/recording-and-playing-audio/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To run this:
2222
```
2323
python audio_recorder.py -d 5 -o recorded.wav
2424
```
25-
- To play audio, there are 3 options (`audio_player_1.py` using [playsound](), `audio_player_2.py` using [pydub](), `audio_player_3.py` using [pyaudio]()):
25+
- To play audio, there are 3 options (`audio_player_playsound.py` using [playsound](https://pypi.org/project/playsound/), `audio_player_pydub.py` using [pydub](https://github.com/jiaaro/pydub), `audio_player_pyaudio.py` using [pyaudio](https://people.csail.mit.edu/hubert/pyaudio/)), if you want to play `audio_file.mp3`::
2626
```
27-
python audio_player.py --help
27+
python audio_player_playsound.py audio_file.mp3
2828
```
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from playsound import playsound
2+
import sys
23

3-
playsound("recorded.wav")
4+
playsound(sys.argv[1])

general/recording-and-playing-audio/audio_player_pyaudio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import pyaudio
22
import wave
3+
import sys
34

4-
filename = "audio_file.wav"
5+
filename = sys.argv[1]
56

67
# set the chunk size of 1024 samples
78
chunk = 1024

general/recording-and-playing-audio/audio_player_pydub.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from pydub import AudioSegment
22
from pydub.playback import play
3+
import sys
34

45
# read MP3 file
5-
song = AudioSegment.from_mp3("audio_file.mp3")
6+
song = AudioSegment.from_mp3(sys.argv[1])
67
# song = AudioSegment.from_wav("audio_file.wav")
78
# you can also read from other formats such as MP4
89
# song = AudioSegment.from_file("audio_file.mp4", "mp4")

0 commit comments

Comments
 (0)