Spaces:
Sleeping
Sleeping
dlaiu
commited on
Commit
·
26ba744
1
Parent(s):
fb031e1
returning a dataframe?
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import parselmouth
|
3 |
from parselmouth.praat import call
|
4 |
import numpy as np
|
|
|
5 |
|
6 |
def get_pitch(audio_data):
|
7 |
rate, data = audio_data
|
@@ -16,7 +17,11 @@ def get_pitch(audio_data):
|
|
16 |
pitch = call(sound, "To Pitch", 0.0, 75, 500)
|
17 |
pitch_values = pitch.selected_array['frequency']
|
18 |
# return "Pitch frequencies: " + str(pitch_values)
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
except Exception as e:
|
21 |
return "Error in pitch extraction: " + str(e)
|
22 |
|
|
|
2 |
import parselmouth
|
3 |
from parselmouth.praat import call
|
4 |
import numpy as np
|
5 |
+
import pandas as pd
|
6 |
|
7 |
def get_pitch(audio_data):
|
8 |
rate, data = audio_data
|
|
|
17 |
pitch = call(sound, "To Pitch", 0.0, 75, 500)
|
18 |
pitch_values = pitch.selected_array['frequency']
|
19 |
# return "Pitch frequencies: " + str(pitch_values)
|
20 |
+
pitch_values[pitch_values==0] = np.nan
|
21 |
+
df_pitch = pd.DataFrame(np.column_stack([pitch.xs(), pitch_values]),
|
22 |
+
columns=['time', 'pitch'])
|
23 |
+
|
24 |
+
return df_pitch
|
25 |
except Exception as e:
|
26 |
return "Error in pitch extraction: " + str(e)
|
27 |
|