Hev832 commited on
Commit
c313ae5
·
verified ·
1 Parent(s): 157260f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -4,6 +4,10 @@ import numpy as np
4
  import time
5
  from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError
6
 
 
 
 
 
7
  def pad_buffer(audio):
8
  # Pad buffer to multiple of 2 bytes
9
  buffer_size = len(audio)
@@ -12,7 +16,8 @@ def pad_buffer(audio):
12
  audio = audio + b'\0' * (element_size - (buffer_size % element_size))
13
  return audio
14
 
15
- def generate_voice(text, voice_name, api_key):
 
16
  set_api_key(api_key) #set API key
17
  try:
18
  audio = generate(
@@ -30,19 +35,12 @@ def generate_voice(text, voice_name, api_key):
30
  # Eleven Multilingual V2 is the world's best Text-to-Speech model. Features 38 voices and supports 28 languages. Sign up on [ElevenLabs](https://elevenlabs.io/?from=partnerpierce7156) to get an API Key.
31
  # """
32
 
33
- with gr.Blocks(theme='Nymbo/Alyx_Theme') as block:
34
- #gr.Markdown('[ ![ElevenLabs](https://user-images.githubusercontent.com/12028621/262629275-4f85c9cf-85b6-435e-ab50-5b8c7c4e9dd2.png) ](https://elevenlabs.io)')
35
- #gr.Markdown("# <center> ElevenLabs </center>")
36
  #gr.Markdown(description)
37
 
38
  with gr.Row(variant='panel'):
39
- input_api_key = gr.Textbox(
40
- type='password',
41
- label='ElevenLabs API Key',
42
- placeholder='Enter your API key',
43
- elem_id="input_api_key"
44
- )
45
-
46
  all_voices = voices()
47
  input_voice = gr.Dropdown(
48
  [ voice.name for voice in all_voices ],
@@ -71,7 +69,7 @@ with gr.Blocks(theme='Nymbo/Alyx_Theme') as block:
71
  format="mp3"
72
  )
73
 
74
- inputs = [input_text, input_voice, input_api_key]
75
  outputs = [out_audio]
76
 
77
  run_button.click(
@@ -81,4 +79,9 @@ with gr.Blocks(theme='Nymbo/Alyx_Theme') as block:
81
  queue=True
82
  )
83
 
 
 
 
 
 
84
  block.queue(concurrency_count=5).launch(debug=True)
 
4
  import time
5
  from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError
6
 
7
+
8
+
9
+
10
+
11
  def pad_buffer(audio):
12
  # Pad buffer to multiple of 2 bytes
13
  buffer_size = len(audio)
 
16
  audio = audio + b'\0' * (element_size - (buffer_size % element_size))
17
  return audio
18
 
19
+ def generate_voice(text, voice_name):
20
+ api_key = os.environ.get(eleven_api_key)
21
  set_api_key(api_key) #set API key
22
  try:
23
  audio = generate(
 
35
  # Eleven Multilingual V2 is the world's best Text-to-Speech model. Features 38 voices and supports 28 languages. Sign up on [ElevenLabs](https://elevenlabs.io/?from=partnerpierce7156) to get an API Key.
36
  # """
37
 
38
+ with gr.Blocks(theme='Hev832/Applio') as block:
39
+ gr.Markdown('[ ![ElevenLabs](https://user-images.githubusercontent.com/12028621/262629275-4f85c9cf-85b6-435e-ab50-5b8c7c4e9dd2.png) ](https://elevenlabs.io)')
40
+ gr.Markdown("# <center> ElevenLabs </center>")
41
  #gr.Markdown(description)
42
 
43
  with gr.Row(variant='panel'):
 
 
 
 
 
 
 
44
  all_voices = voices()
45
  input_voice = gr.Dropdown(
46
  [ voice.name for voice in all_voices ],
 
69
  format="mp3"
70
  )
71
 
72
+ inputs = [input_text, input_voice]
73
  outputs = [out_audio]
74
 
75
  run_button.click(
 
79
  queue=True
80
  )
81
 
82
+
83
+
84
+
85
+
86
+
87
  block.queue(concurrency_count=5).launch(debug=True)