From 5d4f8d6357974b8f8c2fee205d423438ab1d07f6 Mon Sep 17 00:00:00 2001
From: Adam Blank <blank@caltech.edu>
Date: Sat, 12 Oct 2024 00:32:06 +0000
Subject: [PATCH] Add new file

---
 03/util.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 03/util.py

diff --git a/03/util.py b/03/util.py
new file mode 100644
index 0000000..a4a70b1
--- /dev/null
+++ b/03/util.py
@@ -0,0 +1,14 @@
+from pyt2s.services import stream_elements
+from pydub import AudioSegment
+from pydub.playback import play as p
+import io
+
+
+def play(script):
+    play_with_voice(script, "Amy")
+
+
+def play_with_voice(script, voice):
+    data = stream_elements.requestTTS(script, voice)
+    song = AudioSegment.from_file(io.BytesIO(data), format="mp3")
+    p(song)
-- 
GitLab