|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
import torch |
|
|
import os |
|
|
|
|
|
pipe = pipeline('audio-classification', model='mrfakename/styletts2-detector', device='cuda' if torch.cuda.is_available() else 'cpu') |
|
|
|
|
|
|
|
|
ABOUT = """ |
|
|
# 🤔 Did StyleTTS 2 Generate It? |
|
|
|
|
|
[Model](https://huggingface.co/mrfakename/styletts2-detector) |
|
|
|
|
|
An audio classification model based on Whisper to detect StyleTTS 2 audio (also works with Kokoro TTS!). Please share incorrect results in the Community tab! |
|
|
|
|
|
**NOTE: Not affiliated with the author(s) of StyleTTS 2 in any way.** |
|
|
""" |
|
|
|
|
|
DISCLAIMER = """ |
|
|
## Disclaimer |
|
|
|
|
|
The author(s) of this model cannot guarantee complete accuracy. False positives or negatives may occur. |
|
|
|
|
|
Usage of this model should not replace other precautions, such as invisible watermarking or audio watermarking. |
|
|
|
|
|
This model has been trained on outputs from the StyleTTS 2 base model, not fine-tunes. The model may not identify fine-tunes properly. |
|
|
|
|
|
The author(s) of this model disclaim all liability related to or in connection with the usage of this model. |
|
|
""" |
|
|
|
|
|
def classify(audio, model): |
|
|
if model == "turbo": |
|
|
result = pipe_turbo(audio) |
|
|
else: |
|
|
result = pipe(audio) |
|
|
res = {} |
|
|
for r in result: |
|
|
res[r['label']] = r['score'] |
|
|
return res |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown(ABOUT) |
|
|
aud = gr.Audio(label="Upload audio...", interactive=True, type="filepath") |
|
|
|
|
|
btn = gr.Button("Classify", variant="primary") |
|
|
res = gr.Label(label="Results...") |
|
|
|
|
|
btn.click(classify, inputs=[aud], outputs=res) |
|
|
gr.Markdown(DISCLAIMER) |
|
|
|
|
|
demo.queue(default_concurrency_limit=20, max_size=20, api_open=False).launch(show_api=False) |