Update utils.py
Browse files
utils.py
CHANGED
@@ -46,16 +46,12 @@ def txt2story(prompt: str, top_k: int, top_p: float, temperature: float) -> str:
|
|
46 |
return story
|
47 |
|
48 |
# Text-to-speech
|
49 |
-
def txt2speech(text: str)
|
50 |
print("Initializing text-to-speech conversion...")
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
response = requests.post(API_URL, headers=headers, json=payloads)
|
56 |
-
|
57 |
-
with open('audio_story.mp3', 'wb') as file:
|
58 |
-
file.write(response.content)
|
59 |
|
60 |
# Get user preferences for the story
|
61 |
def get_user_preferences() -> Dict[str, str]:
|
|
|
46 |
return story
|
47 |
|
48 |
# Text-to-speech
|
49 |
+
def txt2speech(text: str):
|
50 |
print("Initializing text-to-speech conversion...")
|
51 |
+
|
52 |
+
audio_model = pipeline("text-to-speech", model="myshell-ai/MeloTTS-English")
|
53 |
+
speech = captioning_model(text, max_new_tokens=200)[0]["generated_speech"]
|
54 |
+
return speech
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# Get user preferences for the story
|
57 |
def get_user_preferences() -> Dict[str, str]:
|