Spaces:
Sleeping
Sleeping
Mostafa Shahin
commited on
Commit
•
1bd17d3
1
Parent(s):
6403fc5
plot waveform
Browse files- app.py +18 -10
- phoneme_vocab.json +1 -1
app.py
CHANGED
@@ -98,25 +98,33 @@ def create_spectrogram_with_att(wav_file, att_contour, att ):
|
|
98 |
|
99 |
# Calculate the spectrogram
|
100 |
f, t, Sxx = spectrogram(data, fs=sampling_rate)
|
101 |
-
fig,
|
102 |
|
103 |
# Plot the spectrogram
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
111 |
# Plot the att contour
|
112 |
x_points = att_contour.shape[0]
|
113 |
-
time_att = np.arange(0, x_points * 0.02, 0.02)[:x_points]
|
114 |
ax_att.plot(time_att, att_contour, color='blue', label=f'{att} Contour')
|
115 |
ax_att.set_ylim(0,1)
|
116 |
ax_att.legend()
|
117 |
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
119 |
|
|
|
|
|
120 |
|
121 |
def plot_contour(audio_file, att):
|
122 |
indx_n = engine.processor.tokenizer.convert_tokens_to_ids([f'n_{att}'])[0]
|
|
|
98 |
|
99 |
# Calculate the spectrogram
|
100 |
f, t, Sxx = spectrogram(data, fs=sampling_rate)
|
101 |
+
fig, axs = plt.subplots(2, 1, figsize=(10, 10), sharex=True)
|
102 |
|
103 |
# Plot the spectrogram
|
104 |
+
axs[0].pcolormesh(t, f, 10 * np.log10(Sxx), shading='gouraud') # Use grayscale colormap
|
105 |
+
#plt.colorbar(label='Intensity (dB)')
|
106 |
+
axs[0].set_ylabel('Frequency (Hz)')
|
107 |
+
axs[0].set_xlabel('Time (s)')
|
108 |
+
axs[0].set_title(f'Spectrogram with {att} Contour')
|
109 |
+
axs[0].set_ylim(0, 8000) # Adjust the frequency range if necessary
|
110 |
+
|
111 |
+
ax_att = axs[0].twinx()
|
112 |
# Plot the att contour
|
113 |
x_points = att_contour.shape[0]
|
114 |
+
time_att = np.arange(0, x_points * 0.02, 0.02)[:x_points] # Assuming pitch_contour is sampled every 20 ms
|
115 |
ax_att.plot(time_att, att_contour, color='blue', label=f'{att} Contour')
|
116 |
ax_att.set_ylim(0,1)
|
117 |
ax_att.legend()
|
118 |
|
119 |
+
# Plot the waveform
|
120 |
+
time = np.arange(0, len(data)) / sampling_rate
|
121 |
+
axs[1].plot(time, data, color='blue')
|
122 |
+
axs[1].set_ylabel('Amplitude')
|
123 |
+
axs[1].set_xlabel('Time (s)')
|
124 |
+
axs[1].set_title('Waveform')
|
125 |
|
126 |
+
#plt.show()
|
127 |
+
return fig
|
128 |
|
129 |
def plot_contour(audio_file, att):
|
130 |
indx_n = engine.processor.tokenizer.convert_tokens_to_ids([f'n_{att}'])[0]
|
phoneme_vocab.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"<pad>": 0, "
|
|
|
1 |
+
{"<pad>": 0, "\u0251": 1, "\u00e6": 2, "\u028c": 3, "\u0254": 4, "a\u028a": 5, "a\u026a": 6, "\u025b": 7, "\u025d": 8, "e\u026a": 9, "\u026a": 10, "i": 11, "o\u028a": 12, "\u0254\u026a": 13, "\u028a": 14, "u": 15, "b": 16, "t\u0283": 17, "d": 18, "\u00f0": 19, "f": 20, "g": 21, "h": 22, "d\u0292": 23, "k": 24, "l": 25, "m": 26, "n": 27, "\u014b": 28, "p": 29, "\u0279": 30, "s": 31, "\u0283": 32, "t": 33, "\u03b8": 34, "v": 35, "w": 36, "j": 37, "z": 38, "\u0292": 39}
|