Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from discord import app_commands
|
|
6 |
from typing import List
|
7 |
from elevenlabs import set_api_key, voices, generate, Voice, VoiceSettings, User
|
8 |
import tempfile
|
|
|
9 |
import speech_recognition as sr
|
10 |
from pydub import AudioSegment
|
11 |
import logging
|
@@ -81,8 +82,8 @@ async def voice_create(
|
|
81 |
text: str,
|
82 |
voice_name: str,
|
83 |
stability: float = 0.9,
|
84 |
-
clarity: float = 0.
|
85 |
-
style: float = 0.
|
86 |
):
|
87 |
await interaction.response.defer()
|
88 |
|
@@ -112,9 +113,13 @@ async def voice_create(
|
|
112 |
)
|
113 |
)
|
114 |
|
115 |
-
# Save audio to temporary file
|
116 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".
|
117 |
-
|
|
|
|
|
|
|
|
|
118 |
temp_path = temp_file.name
|
119 |
|
120 |
# Get updated credits
|
@@ -123,8 +128,8 @@ async def voice_create(
|
|
123 |
|
124 |
embed = discord.Embed(
|
125 |
title="Voice Generated",
|
126 |
-
description=f"
|
127 |
-
color=
|
128 |
)
|
129 |
await interaction.followup.send(
|
130 |
embed=embed,
|
|
|
6 |
from typing import List
|
7 |
from elevenlabs import set_api_key, voices, generate, Voice, VoiceSettings, User
|
8 |
import tempfile
|
9 |
+
import io
|
10 |
import speech_recognition as sr
|
11 |
from pydub import AudioSegment
|
12 |
import logging
|
|
|
82 |
text: str,
|
83 |
voice_name: str,
|
84 |
stability: float = 0.9,
|
85 |
+
clarity: float = 0.75,
|
86 |
+
style: float = 0.5
|
87 |
):
|
88 |
await interaction.response.defer()
|
89 |
|
|
|
113 |
)
|
114 |
)
|
115 |
|
116 |
+
# Save audio to temporary WAV file with correct format
|
117 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_file:
|
118 |
+
# Convert audio to proper WAV format using pydub
|
119 |
+
audio_segment = AudioSegment.from_file(io.BytesIO(audio), format="mp3")
|
120 |
+
# Convert to mono, 16-bit PCM at 22.050 kHz
|
121 |
+
audio_segment = audio_segment.set_frame_rate(22050).set_channels(1).set_sample_width(2)
|
122 |
+
audio_segment.export(temp_file.name, format='wav')
|
123 |
temp_path = temp_file.name
|
124 |
|
125 |
# Get updated credits
|
|
|
128 |
|
129 |
embed = discord.Embed(
|
130 |
title="Voice Generated",
|
131 |
+
description=f"Prompt: {text}\nVoice: {voice_name}\nStability: {stability}\nClarity: {clarity}\nStyle: {style}\n\n{credits_msg}",
|
132 |
+
color=0x57F287 # Discord green color
|
133 |
)
|
134 |
await interaction.followup.send(
|
135 |
embed=embed,
|