Update audio.py
Browse files
audio.py
CHANGED
@@ -1,6 +1,18 @@
|
|
1 |
import random
|
2 |
import numpy as np
|
3 |
-
from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def pad_buffer(audio):
|
6 |
# Pad buffer to multiple of 2 bytes
|
@@ -17,6 +29,7 @@ def generate_voice(text):
|
|
17 |
voice="Arnold",
|
18 |
model="eleven_monolingual_v1"
|
19 |
)
|
|
|
20 |
return (44100, np.frombuffer(pad_buffer(audio), dtype=np.int16))
|
21 |
except UnauthenticatedRateLimitError as e:
|
22 |
raise gr.Error("Thanks for trying out ElevenLabs TTS! You've reached the free tier limit. Please provide an API key to continue.")
|
|
|
1 |
import random
|
2 |
import numpy as np
|
3 |
+
from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError, save
|
4 |
+
# import huggingface_hub
|
5 |
+
# from huggingface_hub import Repository
|
6 |
+
# import os
|
7 |
+
|
8 |
+
# DATASET_REPO_URL = "https://huggingface.co/datasets/laxsvips/audiofiles"
|
9 |
+
# DATA_FILENAME = "audio.mp4"
|
10 |
+
# DATA_FILE = os.path.join("data", DATA_FILENAME)
|
11 |
+
|
12 |
+
# HF_TOKEN = os.environ.get("HF_TOKEN")
|
13 |
+
# repo = Repository(
|
14 |
+
# local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
15 |
+
# )
|
16 |
|
17 |
def pad_buffer(audio):
|
18 |
# Pad buffer to multiple of 2 bytes
|
|
|
29 |
voice="Arnold",
|
30 |
model="eleven_monolingual_v1"
|
31 |
)
|
32 |
+
save(audio,'data/audio.mp4')
|
33 |
return (44100, np.frombuffer(pad_buffer(audio), dtype=np.int16))
|
34 |
except UnauthenticatedRateLimitError as e:
|
35 |
raise gr.Error("Thanks for trying out ElevenLabs TTS! You've reached the free tier limit. Please provide an API key to continue.")
|