prosalign / app.py
clr's picture
Update app.py
ef72cdf
raw
history blame
2.06 kB
import gradio as gr
import subprocess,os
from datasets import load_dataset, Audio
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
def setup():
r0 = subprocess.run(["pwd"], capture_output=True, text=True)
print('PWD::', r0.stdout)
r1 = subprocess.run(["wget", "https://github.com/google/REAPER/archive/refs/heads/master.zip"], capture_output=True, text=True)
print(r1.stdout)
subprocess.run(["unzip", "./master.zip"])
subprocess.run(["mv", "REAPER-master", "REAPER"])
subprocess.run(["rm", "./master.zip"])
os.chdir('./REAPER')
subprocess.run(["mkdir", "build"])
os.chdir('./build')
r2 = subprocess.run(["cmake", ".."], capture_output=True, text=True)
print(r2.stdout)
r3 = subprocess.run(["make"], capture_output=True, text=True)
print(r3.stdout)
os.chdir('../..')
r9 = subprocess.run(["ls", "-la"], capture_output=True, text=True)
print('LS::', r9.stdout)
#print('about to setup')
#setup()
def load_lang(langname):
if langname=="Icelandic":
dsname = "language-and-voice-lab/samromur_asr"
ds = load_dataset(dsname,split='validation')#, streaming=True)
ds = ds.cast_column("audio", Audio(sampling_rate=16_000))
df = ds.data.to_pandas()
df = df.drop(columns=['audio', 'speaker_id','duration'])
return df
def f1():
fig = plt.figure(figsize=(10,4))
plt.axline((0,0),slope=1,color="darkgray")
plt.xlabel("Vowel length (ms)")
plt.ylabel("Consonant length (ms)")
return(fig)
bl = gr.Blocks()
with bl:
btn1 = gr.Button(value="The random prosody button")
btn1.style(full_width=False, size="sm")
pl1 = gr.Plot()
btn1.click(f1, [], pl1)
lloadr = gr.Dropdown(["Faroese", "Icelandic"], label="Language", info="Load data for selection...")
with gr.Row():
databrowser = gr.DataFrame(wrap=True, max_rows=50, interactive=False, overflow_row_behaviour='paginate')
lloadr.change(load_lang,lloadr,databrowser)
if __name__ == "__main__":
bl.launch()