Lưu tệp wav trong python

def write_wav[iring, path=None, *args, **kwargs]:
    """Write data as Wave files [.wav].

    Args:
        iring [Ring or Block]: Input data source.
        path [str]: Path specifying where to write output files.
        *args: Arguments to ``bifrost.pipeline.TransformBlock``.
        **kwargs: Keyword Arguments to ``bifrost.pipeline.TransformBlock``.

    **Tensor semantics**::

        Input: [time, pol], dtype = u8 or i*, space = SYSTEM
        Output: Wave file, one file per sequence

        Input: [batch, time, pol], dtype = u8 or i*, space = SYSTEM
        Output: Wave file, one file per batch element

    Returns:
        WavSinkBlock: A new block instance.

    Note:
        The chunk_size and data_size entries in the output wav header are
        written as zero values because they are not known a-priori in a
        streaming setting. VLC still plays the files just fine, but any
        subchunks that appear after the data will be misinterpreted as data.
    """
    return WavSinkBlock[iring, path, *args, **kwargs] 

Các tệp âm thanh là một phương tiện phổ biến để truyền thông tin. Vì vậy, hãy xem cách làm việc với các tệp âm thanh bằng Python. Python cung cấp một mô-đun có tên là pydub để làm việc với các tệp âm thanh. pydub là một thư viện Python chỉ hoạt động với. tập tin wav. Bằng cách sử dụng thư viện này, chúng tôi có thể phát, tách, hợp nhất, chỉnh sửa. tập tin âm thanh wav

Cài đặt

Mô-đun này không được tích hợp sẵn với Python. Để cài đặt, gõ lệnh dưới đây trong thiết bị đầu cuối

pip install pydub

Sau đây là một số chức năng có thể được thực hiện bởi pydub

  1. Đang phát tệp âm thanh
  2. Chúng tôi có thể nhận được một số thông tin nhất định của tệp như kênh chiều dài
  3. Tăng/Giảm âm lượng đã cho. tập tin wav
  4. Hợp nhất hai hoặc nhiều tệp âm thanh
  5. Xuất tệp âm thanh
  6. Tách một tập tin âm thanh

Để truy cập các tệp âm thanh đầu vào, hãy nhấp vào đây. Hãy xem mã cho một số chức năng của thư viện pydub

1] Phát tệp âm thanh. Điều này được thực hiện bằng cách sử dụng phương thức play[]

Python3




pip install pydub
42

pip install pydub
43
pip install pydub
44____145
pip install pydub
46

pip install pydub
43
pip install pydub
48
pip install pydub
45
22050
1
2
17106
60000
50
1

 

22050
1
2
17106
60000
50
2

22050
1
2
17106
60000
50
3

22050
1
2
17106
60000
50
4

22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
7
22050
1
2
17106
60000
50
8
22050
1
2
17106
60000
50
6
pip install pydub
10
pip install pydub
11

pip install pydub
12
pip install pydub
13
22050
1
2
17106
60000
50
6
pip install pydub
15
pip install pydub
16

 

pip install pydub
17

pip install pydub
18

đầu ra

https. //phương tiện truyền thông. chuyên viên máy tính. org/wp-content/uploads/20200811180636/Mẫu. làn sóng

2] Biết về. tập tin wav. đối với điều này, chúng tôi sẽ sử dụng các thuộc tính của đối tượng tệp âm thanh

Python3




pip install pydub
19

pip install pydub
43
pip install pydub
44____145
pip install pydub
46

 

pip install pydub
424

22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
7_______28
22050
1
2
17106
60000
50
6
pip install pydub
10
pip install pydub
11____113
22050
1
2
17106
60000
50
6
pip install pydub
15
pip install pydub
16

 

pip install pydub
436

pip install pydub
437
pip install pydub
438
pip install pydub
439
pip install pydub
440

pip install pydub
441

 

pip install pydub
442

pip install pydub
437
pip install pydub
444

pip install pydub
445

 

pip install pydub
446

pip install pydub
437____1448

pip install pydub
449

 

pip install pydub
450

pip install pydub
437
pip install pydub
452

pip install pydub
453

 

 

pip install pydub
454

pip install pydub
437
pip install pydub
456
pip install pydub
457
pip install pydub
16

pip install pydub
459

 

pip install pydub
460

pip install pydub
437
pip install pydub
438
pip install pydub
463
pip install pydub
440

pip install pydub
465

 

pip install pydub
466

pip install pydub
467

pip install pydub
468

pip install pydub
466

pip install pydub
430
22050
1
2
17106
60000
50
6
pip install pydub
432
pip install pydub
433
pip install pydub
16

pip install pydub
437
pip install pydub
436

đầu ra

22050
1
2
17106
60000
50

3] Tăng/Giảm dung lượng của file. Bằng cách sử dụng toán tử '+' và '-'

Python3




pip install pydub
19

pip install pydub
45
pip install pydub
44

pip install pydub
43
pip install pydub
48
pip install pydub
45
22050
1
2
17106
60000
50
1

 

22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
pip install pydub
486
22050
1
2
17106
60000
50
8
22050
1
2
17106
60000
50
6
pip install pydub
10
pip install pydub
11

22050
1
2
17106
60000
50
01
pip install pydub
13
22050
1
2
17106
60000
50
6
pip install pydub
15
pip install pydub
16

22050
1
2
17106
60000
50
06

22050
1
2
17106
60000
50
07
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
10
22050
1
2
17106
60000
50
11

 

22050
1
2
17106
60000
50
12

22050
1
2
17106
60000
50
13
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
16
22050
1
2
17106
60000
50
17

 

22050
1
2
17106
60000
50
18

22050
1
2
17106
60000
50
19

 

22050
1
2
17106
60000
50
20

pip install pydub
18

 

22050
1
2
17106
60000
50
22

22050
1
2
17106
60000
50
23

 

22050
1
2
17106
60000
50
24

đầu ra

https. //phương tiện truyền thông. chuyên viên máy tính. org/wp-content/uploads/20200811182026/output2. làn sóng

4] Hợp nhất các tập tin. Điều này được thực hiện bằng toán tử '+'

Python3




pip install pydub
42

pip install pydub
43
pip install pydub
44____145
pip install pydub
46

pip install pydub
43
pip install pydub
48
pip install pydub
45
22050
1
2
17106
60000
50
1

 

22050
1
2
17106
60000
50
34
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
7____237
pip install pydub
16

22050
1
2
17106
60000
50
39
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
7
pip install pydub
10
pip install pydub
16

 

22050
1
2
17106
60000
50
44

22050
1
2
17106
60000
50
45
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
34
22050
1
2
17106
60000
50
10
22050
1
2
17106
60000
50
39

22050
1
2
17106
60000
50
50

22050
1
2
17106
60000
50
51

22050
1
2
17106
60000
50
52

đầu ra

https. //phương tiện truyền thông. chuyên viên máy tính. org/wp-content/uploads/20200811180732/Output3. làn sóng

5] Xuất tập tin. Điều này được thực hiện bằng phương thức export[]

Python3




22050
1
2
17106
60000
50
53

pip install pydub
43
pip install pydub
44____145
pip install pydub
46

22050
1
2
17106
60000
50
50

22050
1
2
17106
60000
50
59

22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
7____110
pip install pydub
16

pip install pydub
466

22050
1
2
17106
60000
50
66
22050
1
2
17106
60000
50
67

22050
1
2
17106
60000
50
66
22050
1
2
17106
60000
50
69

22050
1
2
17106
60000
50
66
22050
1
2
17106
60000
50
71

 

pip install pydub
466

22050
1
2
17106
60000
50
73
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
5
22050
1
2
17106
60000
50
10
22050
1
2
17106
60000
50
11

 

22050
1
2
17106
60000
50
78

22050
1
2
17106
60000
50
79
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
81
pip install pydub
11

22050
1
2
17106
60000
50
83
pip install pydub
13
22050
1
2
17106
60000
50
6
pip install pydub
15
pip install pydub
16

đầu ra

https. //phương tiện truyền thông. chuyên viên máy tính. org/wp-content/uploads/20200811180631/louder_wav_file. làn sóng

6] Tách âm thanh. Tách âm thanh bằng phương thức split_to_mono[]

Python3




pip install pydub
42

pip install pydub
43
pip install pydub
44____145
pip install pydub
46

pip install pydub
43
pip install pydub
48
pip install pydub
45
22050
1
2
17106
60000
50
1

 

22050
1
2
17106
60000
50
97

22050
1
2
17106
60000
50
98
22050
1
2
17106
60000
50
6
22050
1
2
17106
60000
50
7____1101
pip install pydub
16

 

pip install pydub
103

pip install pydub
104
22050
1
2
17106
60000
50
6
pip install pydub
106

pip install pydub
437
pip install pydub
108

pip install pydub
437
pip install pydub
110
pip install pydub
111
pip install pydub
112

 

 

pip install pydub
113
pip install pydub
111
pip install pydub
115
22050
1
2
17106
60000
50
6
pip install pydub
117
pip install pydub
11
pip install pydub
13
22050
1
2
17106
60000
50
6
pip install pydub
15
pip install pydub
16

Python có thể phát tệp WAV không?

Kết luận. Phát và ghi âm thanh bằng Python . Play a large range of audio formats, including WAV, MP3 and NumPy arrays.

Tệp WAV được lưu trữ như thế nào?

Định dạng WAV là một trong những định dạng đơn giản nhất để lưu trữ thông tin âm thanh. Dữ liệu được lưu trữ " ở dạng thô " mà không cần xử lý trước. Định dạng WAV là định dạng độc quyền của Microsoft và là trường hợp đặc biệt của định dạng RIFF [Định dạng tệp trao đổi tài nguyên].

Chủ Đề