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']