Spaces:
Sleeping
Sleeping
Delete audio_gen.py
Browse files- audio_gen.py +0 -44
audio_gen.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from typing import List
|
| 3 |
-
import replicate
|
| 4 |
-
from dotenv import load_dotenv
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
load_dotenv()
|
| 8 |
-
replicate_client = replicate.Client(api_token= os.getenv("REPLICATE_API_KEY"))
|
| 9 |
-
|
| 10 |
-
def audio_generation(
|
| 11 |
-
scripts: str,
|
| 12 |
-
voice_id: str,
|
| 13 |
-
speed: float,
|
| 14 |
-
volume: float,
|
| 15 |
-
pitch: int,
|
| 16 |
-
emotion: str
|
| 17 |
-
):
|
| 18 |
-
output = replicate_client.run(
|
| 19 |
-
"minimax/speech-02-turbo",
|
| 20 |
-
input={
|
| 21 |
-
"text": f"""{scripts}""",
|
| 22 |
-
"pitch": pitch,
|
| 23 |
-
"speed": speed,
|
| 24 |
-
"volume": volume,
|
| 25 |
-
"bitrate": 128000,
|
| 26 |
-
"channel": "mono",
|
| 27 |
-
"emotion": emotion,
|
| 28 |
-
"voice_id": voice_id,
|
| 29 |
-
"sample_rate": 32000,
|
| 30 |
-
"language_boost": "English",
|
| 31 |
-
"english_normalization": True
|
| 32 |
-
}
|
| 33 |
-
)
|
| 34 |
-
urls: List[str] = []
|
| 35 |
-
if isinstance(output, list) and output:
|
| 36 |
-
first = output[0]
|
| 37 |
-
url = getattr(first, "url", str(first))
|
| 38 |
-
urls = [url]
|
| 39 |
-
elif isinstance(output, str):
|
| 40 |
-
urls = [output]
|
| 41 |
-
elif hasattr(output, "url"):
|
| 42 |
-
urls = [getattr(output, "url")]
|
| 43 |
-
if urls:
|
| 44 |
-
return urls[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|