Skip to content

Commit c017cdf

Browse files
committed
select voices from UI
1 parent 66e57d1 commit c017cdf

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.env.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Azure OpenAI Service
22
AZURE_OPENAI_ENDPOINT="https://<YOUR_AOAI_NAME>.openai.azure.com/"
33
AZURE_OPENAI_API_KEY="<YOUR_API_KEY>"
4-
AZURE_OPENAI_API_VERSION="2024-06-01"
4+
AZURE_OPENAI_API_VERSION="2024-07-01-preview"
55
AZURE_OPENAI_GPT_MODEL="gpt-4o"
66
AZURE_OPENAI_STT_MODEL="whisper"
7-
AZURE_OPENAI_TTS_VOICE="alloy"
87
AZURE_OPENAI_TTS_MODEL="tts-hd"
98
AZURE_OPENAI_EMBEDDING_MODEL="text-embedding-3-large"
109
AZURE_OPENAI_DALLE_MODEL="dall-e-3"

apps/99_streamlit_examples/pages/7_Text_to_speech.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,20 @@
4848
)
4949
st.write(f"You wrote {len(content)} characters.")
5050

51-
if st.button("Convert"):
51+
voice_option = st.selectbox(
52+
"Select voice",
53+
(
54+
"alloy",
55+
"echo",
56+
"fable",
57+
"onyx",
58+
"nova",
59+
"shimmer",
60+
),
61+
)
62+
63+
convert_button = st.button("Convert")
64+
if convert_button and content and voice_option:
5265
client = AzureOpenAI(
5366
api_key=azure_openai_api_key,
5467
api_version=azure_openai_api_version,
@@ -59,7 +72,7 @@
5972
with st.spinner("Converting..."):
6073
response = client.audio.speech.create(
6174
input=content,
62-
voice=getenv("AZURE_OPENAI_TTS_VOICE"),
75+
voice=voice_option,
6376
model=azure_openai_tts_model,
6477
response_format="mp3",
6578
)

0 commit comments

Comments
 (0)