Spaces:
Runtime error
Runtime error
reverting to prior to add version choice
Browse files
app.py
CHANGED
@@ -11,25 +11,14 @@ def get_x(df):
|
|
11 |
def get_y(df):
|
12 |
return df.pattern
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
#def process(Record, Upload, version):
|
21 |
-
# if version == 'remove silence':
|
22 |
-
# return predict(Record, Upload, learn_removeSilence)
|
23 |
-
# elif version == 'plain':
|
24 |
-
# return predict(Record, Upload, learn_plain)
|
25 |
-
|
26 |
-
def predict(Record, Upload, version):
|
27 |
if Upload: path = Upload
|
28 |
else: path = Record
|
29 |
-
|
30 |
-
spec,pred,pred_idx,probs = learn_removeSilence.predict(str(path), with_input=True)
|
31 |
-
elif version == 'plain':
|
32 |
-
spec,pred,pred_idx,probs = learn_plain.predict(str(path), with_input=True)
|
33 |
fig,ax = plt.subplots(figsize=(16,10))
|
34 |
show_image(spec, ax=ax)
|
35 |
ax.invert_yaxis()
|
@@ -42,16 +31,9 @@ description = "This model will predict the pitch accent pattern of a word based
|
|
42 |
|
43 |
article="<p style='text-align: center'><a href='https://mizoru.github.io/blog/2021/12/25/Japanese-pitch.html' target='_blank'>How did I make this and what is it for?</a></p>"
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
examples = [[path, '', 'remove silence'] for path in ex_paths]
|
48 |
|
49 |
enable_queue=True
|
50 |
|
51 |
-
gr.Interface(fn=predict,
|
52 |
-
inputs=[gr.inputs.Audio(source='microphone', type='filepath', optional=True),
|
53 |
-
gr.inputs.Audio(source='upload', type='filepath', optional=True),
|
54 |
-
gr.inputs.Radio(choices=['plain','remove silence'], type="value", default='remove silence', label='version')
|
55 |
-
],
|
56 |
-
outputs= [gr.outputs.Label(num_top_classes=3), gr.outputs.Image(type="plot", label='Spectrogram')], title=title,description=description,article=article,examples=examples).launch(debug=True, enable_queue=enable_queue)
|
57 |
|
|
|
11 |
def get_y(df):
|
12 |
return df.pattern
|
13 |
|
14 |
+
learn = load_learner('xresnet50_pitch3_removeSilence.pkl')
|
15 |
|
16 |
+
labels = learn.dls.vocab
|
17 |
|
18 |
+
def predict(Record, Upload):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if Upload: path = Upload
|
20 |
else: path = Record
|
21 |
+
spec,pred,pred_idx,probs = learn.predict(str(path), with_input=True)
|
|
|
|
|
|
|
22 |
fig,ax = plt.subplots(figsize=(16,10))
|
23 |
show_image(spec, ax=ax)
|
24 |
ax.invert_yaxis()
|
|
|
31 |
|
32 |
article="<p style='text-align: center'><a href='https://mizoru.github.io/blog/2021/12/25/Japanese-pitch.html' target='_blank'>How did I make this and what is it for?</a></p>"
|
33 |
|
34 |
+
examples = [['代わる.mp3'],['大丈夫な.mp3'],['熱くない.mp3'], ['あめー雨.mp3'], ['あめー飴.mp3']]
|
|
|
|
|
35 |
|
36 |
enable_queue=True
|
37 |
|
38 |
+
gr.Interface(fn=predict,inputs=[gr.inputs.Audio(source='microphone', type='filepath', optional=True), gr.inputs.Audio(source='upload', type='filepath', optional=True)], outputs= [gr.outputs.Label(num_top_classes=3), gr.outputs.Image(type="plot", label='Spectrogram')], title=title,description=description,article=article,examples=examples).launch(debug=True, enable_queue=enable_queue)
|
|
|
|
|
|
|
|
|
|
|
39 |
|