Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ from fastapi.responses import FileResponse
|
|
| 3 |
import torch
|
| 4 |
import torchaudio
|
| 5 |
import os
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
# MODEL_DIR = "my_model"
|
|
@@ -50,6 +52,32 @@ model.load_checkpoint(
|
|
| 50 |
)
|
| 51 |
model.to(device)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
def tts_arabic(text: str, audio_file: str) -> str:
|
| 54 |
gpt_cond_latent, speaker_embedding = model.get_conditioning_latents(audio_path=[audio_file])
|
| 55 |
out = model.inference(
|
|
|
|
| 3 |
import torch
|
| 4 |
import torchaudio
|
| 5 |
import os
|
| 6 |
+
from pydantic import BaseModel
|
| 7 |
+
from typing import List, Optional
|
| 8 |
|
| 9 |
|
| 10 |
# MODEL_DIR = "my_model"
|
|
|
|
| 52 |
)
|
| 53 |
model.to(device)
|
| 54 |
|
| 55 |
+
# --------- Define your models ----------
|
| 56 |
+
class BGM(BaseModel):
|
| 57 |
+
file: str
|
| 58 |
+
bgm_volume: float
|
| 59 |
+
|
| 60 |
+
class Sentence(BaseModel):
|
| 61 |
+
sentence_id: int
|
| 62 |
+
speaker: str
|
| 63 |
+
text: str
|
| 64 |
+
prosody_ref: str
|
| 65 |
+
|
| 66 |
+
class Scene(BaseModel):
|
| 67 |
+
scene_id: int
|
| 68 |
+
ambiance: str
|
| 69 |
+
bgm: BGM
|
| 70 |
+
sentences: List[Sentence]
|
| 71 |
+
|
| 72 |
+
class CastMember(BaseModel):
|
| 73 |
+
name: str
|
| 74 |
+
gender: str
|
| 75 |
+
voice_ref: str
|
| 76 |
+
|
| 77 |
+
class StoryInput(BaseModel):
|
| 78 |
+
cast: List[CastMember]
|
| 79 |
+
scenes: List[Scene]
|
| 80 |
+
|
| 81 |
def tts_arabic(text: str, audio_file: str) -> str:
|
| 82 |
gpt_cond_latent, speaker_embedding = model.get_conditioning_latents(audio_path=[audio_file])
|
| 83 |
out = model.inference(
|