Spaces:
Runtime error
Runtime error
dlaiu commited on
Commit ·
ea19a0e
1
Parent(s): a2df844
try again with numpy
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import parselmouth
|
| 3 |
from parselmouth.praat import call
|
|
|
|
| 4 |
|
| 5 |
# def greet(name):
|
| 6 |
# return "Hello " + name + "!!"
|
|
@@ -9,11 +10,12 @@ from parselmouth.praat import call
|
|
| 9 |
# demo.launch()
|
| 10 |
|
| 11 |
|
| 12 |
-
def get_pitch(
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
pitch_values = pitch.selected_array['frequency']
|
| 16 |
-
return "Pitch frequencies: " + str(pitch_values)
|
| 17 |
|
| 18 |
demo = gr.Interface(fn=get_pitch, inputs="audio", outputs="text")
|
| 19 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import parselmouth
|
| 3 |
from parselmouth.praat import call
|
| 4 |
+
import numpy as np
|
| 5 |
|
| 6 |
# def greet(name):
|
| 7 |
# return "Hello " + name + "!!"
|
|
|
|
| 10 |
# demo.launch()
|
| 11 |
|
| 12 |
|
| 13 |
+
def get_pitch(audio_data):
|
| 14 |
+
rate, data = audio_data # Assuming Gradio passes (sampling_rate, numpy_array)
|
| 15 |
+
sound = parselmouth.Sound(values=np.array(data, dtype='float64'), sampling_frequency=rate)
|
| 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 |
demo = gr.Interface(fn=get_pitch, inputs="audio", outputs="text")
|
| 21 |
demo.launch()
|