Spaces:
Runtime error
Runtime error
File size: 1,025 Bytes
de5adc3 47d15fa f709d08 90c85f1 f709d08 90c85f1 f709d08 90c85f1 90b7725 90c85f1 1bb4e73 90c85f1 47d15fa 90c85f1 |
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 |
import os
import torch
import gradio as gr
from diffusers import DiffusionPipeline
import soundfile as sf
# Читаем токен из секрета Hugging Face
HF_HUB_TOKEN = os.environ["HF_HUB_TOKEN"]
# Загружаем pipeline из подпапки GFengG
pipe = DiffusionPipeline.from_pretrained(
"MeiGen-AI/MeiGen-MultiTalk",
subfolder="GFengG",
token=HF_HUB_TOKEN,
torch_dtype=torch.float16
).to("cuda" if torch.cuda.is_available() else "cpu")
def generate(prompt: str):
out = pipe(prompt) # см. README: может быть text2speech, audio2audio и т.п.
audio = out.audios[0]
sf.write("generated.wav", audio, samplerate=pipe.unet.config.sample_rate)
return "generated.wav"
iface = gr.Interface(
fn=generate,
inputs=gr.Textbox(lines=2, placeholder="Введите текст..."),
outputs=gr.Audio(source="file", type="filepath"),
title="MeiGen-MultiTalk Demo"
)
if __name__ == "__main__":
iface.launch(server_name="0.0.0.0", server_port=7860) |