Spaces:
Sleeping
Sleeping
File size: 1,085 Bytes
78decde c08083d a56833a c08083d a56833a c08083d a56833a c08083d 8375f14 c08083d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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
|