MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / write_wav

Function write_wav

examples/csv2wav/csv2wav.py:134–144  ·  view source on GitHub ↗
(audio_float, sample_rate, output_path, dither=False)

Source from the content-addressed store, hash-verified

132
133
134def write_wav(audio_float, sample_rate, output_path, dither=False):
135 num_channels = audio_float.shape[1] if audio_float.ndim > 1 else 1
136 audio_float = remove_dc(audio_float)
137 audio_float = normalize_per_channel(audio_float, headroom_db=0.5)
138 int_data = float_to_int16(audio_float, dither=dither)
139
140 with wave.open(output_path, "w") as wf:
141 wf.setnchannels(num_channels)
142 wf.setsampwidth(2) # 16 bit PCM
143 wf.setframerate(sample_rate)
144 wf.writeframes(int_data.tobytes())
145
146
147def convert_csv_to_wav(

Callers 1

convert_csv_to_wavFunction · 0.85

Calls 4

remove_dcFunction · 0.85
normalize_per_channelFunction · 0.85
float_to_int16Function · 0.85
openMethod · 0.45

Tested by

no test coverage detected