Added function to save the audio files
Browse files
README.md
CHANGED
@@ -70,6 +70,19 @@ import scipy
|
|
70 |
|
71 |
scipy.io.wavfile.write("techno.wav", rate=model.config.sampling_rate, data=output.float().numpy())
|
72 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
Or displayed in a Jupyter Notebook / Google Colab:
|
75 |
|
|
|
70 |
|
71 |
scipy.io.wavfile.write("techno.wav", rate=model.config.sampling_rate, data=output.float().numpy())
|
72 |
```
|
73 |
+
If you find any error while saving the audio file using the above code then you can try the following code
|
74 |
+
|
75 |
+
```python
|
76 |
+
def save_audio_file(output, file):
|
77 |
+
audio_array = output.numpy().squeeze()
|
78 |
+
audio_array /=1.414
|
79 |
+
audio_array *= 32767
|
80 |
+
audio_array = audio_array.astype(np.int16)
|
81 |
+
|
82 |
+
sampling_rate = model.config.sampling_rate
|
83 |
+
|
84 |
+
scipy.io.wavfile.write(f"/root/{file}", rate=sampling_rate, data=audio_array)
|
85 |
+
```
|
86 |
|
87 |
Or displayed in a Jupyter Notebook / Google Colab:
|
88 |
|