Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created November 29, 2024 20:14
Show Gist options
  • Save eyaltrabelsi/0857a7cf5c75ae1ef4fec9c1c3e10b0a to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/0857a7cf5c75ae1ef4fec9c1c3e10b0a to your computer and use it in GitHub Desktop.
audio_dashboard_brief
def text_to_audio(text):
sound_obj = BytesIO()
tts = gTTS(text, lang='en')
tts.write_to_fp(sound_obj)
return sound_obj
def get_audio_brief_for_dashboard(user_id, dashboard_name)
image = plot_stock_data(most_interacted_dashboard)
api_key = os.environ.get("ANTROPIC_API_KEY")
image = base64.b64encode(image.read()).decode("utf-8")
message = anthropic.Anthropic(api_key=api_key).messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user",
"content": [{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": image}},
{"type": "text", "text": DASHBOARD_DEBRIEF_PROMPT}],}],)
return text_to_audio(message.content[0].text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment