Skip to content

Commit

Permalink
select voices from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ks6088ts committed Aug 12, 2024
1 parent 66e57d1 commit c017cdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Azure OpenAI Service
AZURE_OPENAI_ENDPOINT="https://<YOUR_AOAI_NAME>.openai.azure.com/"
AZURE_OPENAI_API_KEY="<YOUR_API_KEY>"
AZURE_OPENAI_API_VERSION="2024-06-01"
AZURE_OPENAI_API_VERSION="2024-07-01-preview"
AZURE_OPENAI_GPT_MODEL="gpt-4o"
AZURE_OPENAI_STT_MODEL="whisper"
AZURE_OPENAI_TTS_VOICE="alloy"
AZURE_OPENAI_TTS_MODEL="tts-hd"
AZURE_OPENAI_EMBEDDING_MODEL="text-embedding-3-large"
AZURE_OPENAI_DALLE_MODEL="dall-e-3"
Expand Down
17 changes: 15 additions & 2 deletions apps/99_streamlit_examples/pages/7_Text_to_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,20 @@
)
st.write(f"You wrote {len(content)} characters.")

if st.button("Convert"):
voice_option = st.selectbox(
"Select voice",
(
"alloy",
"echo",
"fable",
"onyx",
"nova",
"shimmer",
),
)

convert_button = st.button("Convert")
if convert_button and content and voice_option:
client = AzureOpenAI(
api_key=azure_openai_api_key,
api_version=azure_openai_api_version,
Expand All @@ -59,7 +72,7 @@
with st.spinner("Converting..."):
response = client.audio.speech.create(
input=content,
voice=getenv("AZURE_OPENAI_TTS_VOICE"),
voice=voice_option,
model=azure_openai_tts_model,
response_format="mp3",
)
Expand Down

0 comments on commit c017cdf

Please sign in to comment.