Spaces:
Sleeping
Sleeping
File size: 1,329 Bytes
f95686e 3f96ef5 b9637be caa2598 bd282c4 caa2598 f95686e caa2598 b9637be 3f96ef5 b9637be f95686e b9637be f95686e 9d533c6 396ae1b 9d533c6 6fa9d76 f95686e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import gradio as gr
import numpy as np
import matplotlib.pyplot as plt
from manipulate_model.utils import get_config_and_model, infere
manpulate_config, manipulate_model = get_config_and_model()
manipulate_model.eval()
def process(filepath):
global manipulate_model
global manpulate_config
out = infere(manipulate_model, filepath, manpulate_config)
out = out.tolist()
plt.plot(out)
out_masked = np.ma.masked_less_equal(out, 0.4)
plt.plot(out_masked, 'r', linewidth=2)
return str(out), plt
demo = gr.Blocks()
file_proc = gr.Interface(
fn=process,
inputs=[
gr.Audio(sources=["microphone", "upload"], type="filepath", show_download_button=True, label="Speech file (<30s)", max_length=30),
],
outputs=["text",
gr.Plot(label="Frame wise prediction")
],
title="Find the manipulation: Analyze 'Real' or 'Manipulated' audio.",
description=(
"Analyze, detect and localize manipulation in an audio with a click of a button. Upload a .wav or .flac file."
),
examples=[
["./samples/fake_audio.wav"],
["./samples/real_audio.wav"]
],
cache_examples=False,
allow_flagging="never",
)
with demo:
gr.TabbedInterface([file_proc], ["Find Audio Manipulation"])
demo.queue(max_size=10)
demo.launch(share=True) |