Skip to content

Commit ffd09c2

Browse files
committed
w
1 parent 4423067 commit ffd09c2

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

apps/14_streamlit_azure_ai_speech/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ poetry run python -m streamlit run apps/14_streamlit_azure_ai_speech/main.py
1212

1313
- [How to recognize speech](https://learn.microsoft.com/azure/ai-services/speech-service/how-to-recognize-speech?pivots=programming-language-python)
1414
- [Quickstart: Create real-time diarization](https://learn.microsoft.com/azure/ai-services/speech-service/get-started-stt-diarization?tabs=windows&pivots=programming-language-python)
15+
- [Speech to text containers with Docker](https://learn.microsoft.com/azure/ai-services/speech-service/speech-container-stt?tabs=container&pivots=programming-language-python)
1516
- [AzureSpeechService でリアルタイム議事録](https://zenn.dev/o_ken_surprise/articles/991f5b592b91ee)

apps/14_streamlit_azure_ai_speech/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
key="INEFERENCE_TYPE",
2323
)
2424
if inference_type == "local":
25+
path_to_model = st.text_input(
26+
label="PATH_TO_MODEL",
27+
value="./model",
28+
key="PATH_TO_MODEL",
29+
type="default",
30+
)
31+
host = st.text_input(
32+
label="HOST",
33+
value="ws://localhost:5000",
34+
key="HOST",
35+
type="default",
36+
)
2537
st.warning("yet to be implemented")
2638
if inference_type == "azure":
2739
azure_openai_endpoint = st.text_input(

apps/14_streamlit_azure_ai_speech/speech_to_text.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ def init_args() -> argparse.Namespace:
1717
prog="speech_to_text",
1818
description="Azure AI Speech API Speech-to-Text",
1919
)
20+
parser.add_argument(
21+
"-t",
22+
"--type",
23+
default="azure",
24+
help="Inference type, either 'local' or 'azure'",
25+
)
26+
parser.add_argument(
27+
"-h",
28+
"--host",
29+
default="ws://localhost:5000",
30+
help="Host address for local inference",
31+
)
2032
parser.add_argument(
2133
"-s",
2234
"--subscription",
@@ -79,11 +91,20 @@ def start_transcription(args: argparse.Namespace):
7991
global outfilename
8092
outfilename = args.output
8193

82-
speech_config = speechsdk.SpeechConfig(
83-
subscription=args.subscription,
84-
region=args.region,
85-
speech_recognition_language=args.language,
86-
)
94+
speech_config = None
95+
if args.type == "local":
96+
speech_config = speechsdk.SpeechConfig(
97+
host=args.host,
98+
speech_recognition_language=args.language,
99+
)
100+
if args.type == "azure":
101+
speech_config = speechsdk.SpeechConfig(
102+
subscription=args.subscription,
103+
region=args.region,
104+
speech_recognition_language=args.language,
105+
)
106+
if not speech_config:
107+
raise ValueError(f"Invalid inference type: {args.type}")
87108

88109
conversation_transcriber = speechsdk.transcription.ConversationTranscriber(
89110
speech_config=speech_config,

0 commit comments

Comments
 (0)