Spaces:
Sleeping
Sleeping
import openai | |
def generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_speed, language, output_option, summary_length, additional_prompt): | |
# Set API key dynamically | |
openai.api_key = api_key | |
client = openai.OpenAI(api_key=api_key) | |
# Assuming text-to-speech and summarization logic goes here | |
if output_option in ["summary_text", "both"]: | |
text_summary = f"Generated summary for: {input_text[:100]}..." # Replace with real summary generation logic | |
if output_option in ["audio", "both"]: | |
response = client.audio.speech.create( | |
text=input_text, | |
model=model_name, | |
voice=voice_type, | |
language=language, | |
speed=voice_speed | |
) | |
audio_output = response['audio_file'] # Placeholder for the actual audio file output | |
if output_option == "summary_text": | |
return text_summary, None | |
elif output_option == "audio": | |
return None, audio_output | |
elif output_option == "both": | |
return text_summary, audio_output | |
return None, None | |