Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,20 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import numpy as np
|
3 |
-
from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
audio = audio + b'\0' * (element_size - (buffer_size % element_size))
|
10 |
-
return audio
|
11 |
-
|
12 |
-
def generate_voice(text, voice_name):
|
13 |
-
model_name = "eleven_multilingual_v1"
|
14 |
-
try:
|
15 |
-
audio = generate(
|
16 |
-
text[:250],
|
17 |
-
voice=voice_name,
|
18 |
-
model=model_name
|
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.")
|
23 |
-
except Exception as e:
|
24 |
-
raise gr.Error(str(e))
|
25 |
-
|
26 |
-
all_voices = voices()
|
27 |
-
desired_voices = ["Antonio"]
|
28 |
-
filtered_voices = [voice.name for voice in all_voices if voice.name in desired_voices]
|
29 |
-
|
30 |
-
input_text = gr.Textbox(label="Input Text", lines=2)
|
31 |
-
input_voice = gr.Dropdown(choices=filtered_voices, default="Antonio", label="Voice")
|
32 |
-
out_audio = gr.Audio(label="Generated Voice", type="numpy")
|
33 |
|
|
|
34 |
iface = gr.Interface(
|
35 |
-
fn=
|
36 |
-
inputs=
|
37 |
-
outputs=
|
38 |
-
live=True
|
|
|
|
|
|
|
|
|
39 |
)
|
40 |
|
41 |
iface.launch()
|
|
|
1 |
+
import gradio as gr
|
|
|
|
|
2 |
|
3 |
+
# Define the function to predict using the model
|
4 |
+
def predict_image(img):
|
5 |
+
model = gr.load("models/google/vit-base-patch16-224")
|
6 |
+
return model.predict(img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
# Create the interface
|
9 |
iface = gr.Interface(
|
10 |
+
fn=predict_image,
|
11 |
+
inputs=gr.Image(),
|
12 |
+
outputs="label",
|
13 |
+
live=True,
|
14 |
+
capture_session=True,
|
15 |
+
title="Image recognition",
|
16 |
+
description="Upload an image you want to categorize.",
|
17 |
+
theme="Monochrome"
|
18 |
)
|
19 |
|
20 |
iface.launch()
|