File size: 285 Bytes
0c5d789
cec610a
0c5d789
cec610a
33a41f1
cec610a
0c5d789
cec610a
 
f4ce211
1
2
3
4
5
6
7
8
9
10

from transformers import pipeline

# Load the TTS model from Hugging Face
tts_model_id = "'gpt2'"  
tts_pipeline = pipeline("text-to-speech", model=tts_model_id)

# Generate speech
result = tts_pipeline("This is the text I want to convert to speech.")
audio_array = result[0]['audio']