laxsvips commited on
Commit
a4a23a5
·
1 Parent(s): 2aec833

Delete audio.py

Browse files
Files changed (1) hide show
  1. audio.py +0 -28
audio.py DELETED
@@ -1,28 +0,0 @@
1
- from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError
2
- import numpy as np
3
- import gradio as gr
4
- import os
5
-
6
- def pad_buffer(audio):
7
- # Pad buffer to multiple of 2 bytes
8
- buffer_size = len(audio)
9
- element_size = np.dtype(np.int16).itemsize
10
- if buffer_size % element_size != 0:
11
- audio = audio + b'\0' * (element_size - (buffer_size % element_size))
12
- return audio
13
-
14
- def generate_audio(text):
15
- try:
16
- eleven_api_key = os.getenv('ELEVEN_API_KEY')
17
- set_api_key(eleven_api_key)
18
-
19
- audio = generate(
20
- text[:250], # Limit to 250 characters
21
- voice="Arnold",
22
- model="eleven_multilingual_v1"
23
- )
24
- return (44100, np.frombuffer(pad_buffer(audio), dtype=np.int16))
25
- except UnauthenticatedRateLimitError as e:
26
- raise gr.Error("Thanks for trying out ElevenLabs TTS! You've reached the free tier limit. Please provide an API key to continue.")
27
- except Exception as e:
28
- raise gr.Error(e)