AmmosSource
guix
Line | |
---|
1 | import sys
|
---|
2 | import os
|
---|
3 | import io
|
---|
4 | from pydub import AudioSegment
|
---|
5 | from pydub.playback import play
|
---|
6 |
|
---|
7 | sys.path.append('../src/')
|
---|
8 |
|
---|
9 | from ammosreader.AmmosAudioReader import AmmosAudioReader
|
---|
10 |
|
---|
11 | if __name__ == '__main__':
|
---|
12 |
|
---|
13 | if len(sys.argv) != 2:
|
---|
14 | sys.exit()
|
---|
15 |
|
---|
16 | file_name = sys.argv[1]
|
---|
17 |
|
---|
18 | print("File name:", file_name)
|
---|
19 |
|
---|
20 | dat_file = AmmosAudioReader(file_name)
|
---|
21 |
|
---|
22 | dat_file.read_all_frames_left()
|
---|
23 | print("Sample rate:", dat_file.container.global_frames[0].global_frame_body.data_header.sample_rate)
|
---|
24 | print("Container size:", dat_file.container.size())
|
---|
25 | pcm_data = dat_file.pcm_for_channel(0)
|
---|
26 | print("PCM data size total:", len(pcm_data))
|
---|
27 | data = AudioSegment.from_raw(io.BytesIO(pcm_data),
|
---|
28 | sample_width=2,
|
---|
29 | frame_rate=22050,
|
---|
30 | channels=1)
|
---|
31 | play(data)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.