Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
fixed /tts
Browse files Browse the repository at this point in the history
  • Loading branch information
xRiddin committed Oct 11, 2023
1 parent 465dc89 commit 9bb838c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions models/tts.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
from gradio_client import Client
from moviepy.editor import concatenate_audioclips, AudioFileClip
import tempfile
import os


def split_message(message, max_length):
words = message.split()
message_parts = []
current_part = ""

for word in words:
if len(current_part) + len(word) + 1 <= max_length:
current_part += word + " "
else:
message_parts.append(current_part.strip())
current_part = word + " "

if current_part:
message_parts.append(current_part.strip())

return message_parts


def generate(message, dire, model="Charlotte"):
client = Client("https://elevenlabs-tts.hf.space/")
max_length = 250
audio_clips = []
message_parts = [message[i:i+max_length] for i in range(0, len(message), max_length)]
message_parts = split_message(message, max_length)
for message_part in message_parts:
audio_path = client.predict(message_part, model, fn_index=0)
audio_clip = AudioFileClip(audio_path)
Expand Down
1 change: 1 addition & 0 deletions yt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests


async def yt(link, websockets):

video_id = getVideoId(link)
Expand Down

0 comments on commit 9bb838c

Please sign in to comment.