In this quickstart, learn how to use the Speech service for real-time speech to text conversion.
Next step
Learn more about speech recognition
Was this page helpful?
⌘I
{"docsConfig":{"theme":"almond","$schema":"https://mintlify.com/docs.json","name":"Microsoft Foundry Docs","colors":{"primary":"#0078D4","light":"#50A0E0","dark":"#003C6B"},"favicon":"https://mintlify.s3.us-west-1.amazonaws.com/hobbyist-e43fa225/images/favicon.png","contextual":{"options":["copy","view",{"title":"Open in GitHub Copilot","description":"Ask questions about this page","icon":"github","href":{"base":"https://github.com/copilot","query":[{"key":"prompt","value":"Read from https://hobbyist-e43fa225.mintlify.app$path so I can ask questions about it."}]}},"chatgpt","claude","perplexity","grok","mcp","add-mcp","vscode",{"title":"Connect to VS Code Insiders","description":"Install MCP server on VS Code Insiders","icon":"https://code.visualstudio.com/assets/branding/code-stable.png","href":"vscode-insiders://mcp/install?%7B%22name%22%3A%22Microsoft%20Foundry%20Docs%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A//hobbyist-e43fa225.mintlify.app/mcp%22%7D"},"cursor"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"hobbyist-e43fa225","hasAudioNarration":false,"actualSubdomain":"hobbyist-e43fa225","customDomains":[],"gitSource":{"type":"github","owner":"nicholasdbrady","repo":"foundry-docs","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":false,"issues":false,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"DISABLED"},"REMOVE_BRANDING":{"status":"DISABLED"},"CONTEXTUAL_FEEDBACK":{"status":"DISABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"DISABLED"},"WEB_MCP":{"status":"DISABLED"},"NARRATION":{"status":"DISABLED"}},"buildId":"6abd7195fe6008b1f9fa4cf0","clientVersion":"0.0.4177","searchFilterCounts":[{"language":"default","tag":"Documentation","count":389},{"language":"default","tag":"Models","count":132},{"language":"default","tag":"Agents","count":105},{"language":"default","tag":"Hosted agents","count":67},{"language":"default","tag":"Toolboxes","count":50},{"language":"default","tag":"Add tools and skills","count":45},{"language":"default","tag":"Evaluation","count":37},{"language":"default","tag":"Developer tools and integrations","count":32},{"language":"default","tag":"Explore Foundry Models","count":26},{"language":"default","tag":"Model capabilities","count":23}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":"#navbar{background:rgb(255, 255, 255);backdrop-filter:blur(12px)}:root.dark #navbar,.dark #navbar{background:rgb(24, 24, 27)}.model-desc{line-height:1.4!important;display:block!important}"}],"page":{"pagePath":"models/get-started-speech-to-text","slug":"/models/get-started-speech-to-text","pageMetadata":{"title":"Speech to text quickstart","description":"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.","sidebarTitle":"Speech to text quickstart","href":"/models/get-started-speech-to-text"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];const ZonePivot=({group,options=[],defaultValue,label=`Choose an experience`})=>{const values=options.map(option=>option.id);const optionKey=options.map(option=>`${option.id}:${option.title}`).join(`|`);const[activePivot,setActivePivot]=useState(defaultValue||values[0]);const slugify=value=>value.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``);const resolvePivot=()=>{if(typeof window===`undefined`)return defaultValue||values[0];const params=new URLSearchParams(window.location.search);const requested=params.get(`pivots`);if(requested){const requestedIds=requested.split(`,`).map(value=>value.trim()).filter(Boolean);const match=requestedIds.find(id=>values.includes(id));if(match)return match}const hash=window.location.hash.replace(/^#/,``);if(hash){const match=options.find(option=>option.id===hash||slugify(option.title)===hash);if(match)return match.id}try{const stored=window.localStorage.getItem(`foundry-zone-pivot:${group}`);if(values.includes(stored))return stored}catch{return defaultValue||values[0]}return defaultValue||values[0]};const publishPivotChange=value=>{if(typeof window===`undefined`)return;window.dispatchEvent(new CustomEvent(`foundry-zone-pivot-change`,{detail:{group,value}}))};const syncTableOfContents=()=>{if(typeof window===`undefined`)return;window.requestAnimationFrame(()=>{const toc=document.getElementById(`table-of-contents-content`);if(!toc)return;const links=Array.from(toc.querySelectorAll(`a[href^=\"#\"]`));for(const link of links){const item=link.closest(`li`);const rawId=link.getAttribute(`href`)?.slice(1);if(!item||!rawId)continue;let id=rawId;try{id=decodeURIComponent(rawId)}catch{}item.style.display=document.getElementById(id)?``:`none`}})};useEffect(()=>{const resolvedPivot=resolvePivot();setActivePivot(resolvedPivot);publishPivotChange(resolvedPivot);window.setTimeout(syncTableOfContents,0)},[group,defaultValue,values.join(`|`),optionKey]);const selectPivot=value=>{setActivePivot(value);if(typeof window!==`undefined`){try{window.localStorage.setItem(`foundry-zone-pivot:${group}`,value)}catch{}const url=new URL(window.location.href);const current=url.searchParams.get(`pivots`);const preserved=current?current.split(`,`).map(id=>id.trim()).filter(id=>id\u0026\u0026!values.includes(id)):[];url.searchParams.set(`pivots`,[...preserved,value].join(`,`));window.history.replaceState(null,``,`${url.pathname}${url.search}${url.hash}`)}publishPivotChange(value);window.setTimeout(syncTableOfContents,0)};if(options.length\u003c2)return null;return _jsxs(`div`,{className:`not-prose mint-my-6 mint-border-b mint-border-slate-200 mint-pb-3 dark:mint-border-slate-800`,children:[_jsx(`div`,{className:`mint-mb-2 mint-text-xs mint-font-semibold mint-uppercase mint-tracking-wide mint-text-slate-500 dark:mint-text-slate-400`,children:label}),_jsx(`div`,{className:`mint-flex mint-flex-wrap mint-gap-2`,role:`tablist`,\"aria-label\":label,children:options.map(option=>{const selected=option.id===activePivot;return _jsx(`button`,{type:`button`,role:`tab`,\"aria-selected\":selected,onClick:()=>selectPivot(option.id),className:`mint-rounded-md mint-border mint-px-3 mint-py-1.5 mint-text-sm mint-font-medium mint-transition ${selected?`mint-border-slate-900 mint-bg-slate-900 mint-text-white mint-shadow-sm dark:mint-border-slate-100 dark:mint-bg-slate-100 dark:mint-text-slate-950`:`mint-border-slate-200 mint-bg-white mint-text-slate-700 hover:mint-border-slate-400 hover:mint-text-slate-950 dark:mint-border-slate-700 dark:mint-bg-slate-950 dark:mint-text-slate-200 dark:hover:mint-border-slate-500`}`,children:option.title},option.id)})})]})};const ZoneContent=({group,value,options=[],values=[],defaultValue,children})=>{const optionKey=options.map(option=>`${option.id}:${option.title}`).join(`|`);const[activePivot,setActivePivot]=useState(defaultValue||values[0]);const slugify=value=>value.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``);const resolvePivot=()=>{if(typeof window===`undefined`)return defaultValue||values[0];const params=new URLSearchParams(window.location.search);const requested=params.get(`pivots`);if(requested){const requestedIds=requested.split(`,`).map(value=>value.trim()).filter(Boolean);const match=requestedIds.find(id=>values.includes(id));if(match)return match}const hash=window.location.hash.replace(/^#/,``);if(hash){const match=options.find(option=>option.id===hash||slugify(option.title)===hash);if(match)return match.id}try{const stored=window.localStorage.getItem(`foundry-zone-pivot:${group}`);if(values.includes(stored))return stored}catch{return defaultValue||values[0]}return defaultValue||values[0]};useEffect(()=>{setActivePivot(resolvePivot())},[group,defaultValue,values.join(`|`),optionKey]);useEffect(()=>{const onPivotChange=event=>{if(event.detail?.group===group\u0026\u0026values.includes(event.detail.value)){setActivePivot(event.detail.value)}};window.addEventListener(`foundry-zone-pivot-change`,onPivotChange);return()=>window.removeEventListener(`foundry-zone-pivot-change`,onPivotChange)},[group,values.join(`|`)]);if(activePivot!==value)return null;return _jsx(_Fragment,{children})};function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,h5:`h5`,hr:`hr`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Card,CodeBlock,Frame,Heading,Info,Note,OptimizedImage,Tab,Tabs,Tip,_MdxComponentBoundary}=_components;if(!Card)_missingMdxReference(`Card`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Note)_missingMdxReference(`Note`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsxs(_Fragment,{children:[_jsx(_MdxComponentBoundary,{name:`ZonePivot`,children:_jsx(ZonePivot,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],defaultValue:`ai-foundry`})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`ai-foundry`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[`In this quickstart, you try real-time speech to text in `,_jsx(_components.a,{href:`https://ai.azure.com/?cid=learnDocs`,children:`Microsoft Foundry`}),`.`]}),_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`Create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`A Foundry project. If you need to create a project, see `,_jsx(_components.a,{href:`https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/create-projects`,children:`Create a Microsoft Foundry project`}),`.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`try-real-time-speech-to-text`,children:`Try real-time speech to text`}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Foundry (new) portal`,id:`foundry-new-portal`,\"data-child-heading-ids\":`[\"other-foundry-new-features\"]`,children:[_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Sign in to `,_jsx(_components.a,{href:`https://ai.azure.com/?cid=learnDocs`,children:`Microsoft Foundry`}),`. Make sure the `,_jsx(_components.strong,{children:`New Foundry`}),` toggle is on. These steps refer to `,_jsx(_components.strong,{children:`Foundry (new)`}),`.`]}),`\n`]}),_jsx(OptimizedImage,{src:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=1338a0cf43c92807e8bcccdd0223d052`,\"data-og-width\":`184`,width:`184`,\"data-og-height\":`36`,height:`36`,\"data-path\":`images/new-foundry.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?w=280\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=31f5310d0bab28c50f0612ed87780767 280w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?w=560\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=b99e76f59478251b758fdecd39e4fe4e 560w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?w=840\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=a75299d9a299ac26fe00fc39bf63bf60 840w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?w=1100\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=d0f25ff0500bbd410d13d9f75fe9ec8c 1100w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?w=1650\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=384dd9cb90f12b342bac4ff81b79b031 1650w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/new-foundry.png?w=2500\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=64cdafe79c9fa79f4e469789ee5715b8 2500w`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Build`}),` from the top right menu.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Models`}),` on the left pane.`]}),`\n`,_jsxs(_components.li,{children:[`The `,_jsx(_components.strong,{children:`AI Services`}),` tab shows the Foundry models that can be used out of the box in the Foundry portal. Select `,_jsx(_components.strong,{children:`Azure Speech - Speech to text`}),` to open the Speech to Text playground.`]}),`\n`,_jsxs(_components.li,{children:[`Optionally use the `,_jsx(_components.strong,{children:`Parameters`}),` section to change the task, language, profanity policy, and other settings. You can also add special instructions for the LLM.`]}),`\n`,_jsxs(_components.li,{children:[`Use the `,_jsx(_components.strong,{children:`Upload files`}),` section to select your audio file. Then select `,_jsx(_components.strong,{children:`Start`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`View the transcription output in the `,_jsx(_components.strong,{children:`Transcript`}),` tab. Optionally view the raw API response output in the `,_jsx(_components.strong,{children:`JSON`}),` tab.`]}),`\n`,_jsxs(_components.li,{children:[`Switch to the `,_jsx(_components.strong,{children:`Code`}),` tab to get the sample code for using the speech to text feature in your application.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`other-foundry-new-features`,children:`Other Foundry (new) features`}),_jsx(_components.p,{children:`The following Speech features are available in the Foundry (new) portal:`}),_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-foundry/agents/how-to/tools/azure-ai-speech`,children:`Speech MCP server`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/get-started-speech-to-text`,children:`Speech to text quickstart`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/get-started-text-to-speech`,children:`Text to speech quickstart`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/text-to-speech-avatar/batch-synthesis-avatar`,children:`Text to speech avatar quickstart`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/voice-live-quickstart`,children:`Voice live quickstart`})}),`\n`]})]}),_jsxs(Tab,{title:`Foundry (classic) portal`,id:`foundry-classic-portal`,children:[_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Sign in to `,_jsx(_components.a,{href:`https://ai.azure.com/?cid=learnDocs`,children:`Microsoft Foundry`}),`. Make sure the `,_jsx(_components.strong,{children:`New Foundry`}),` toggle is off. These steps refer to `,_jsx(_components.strong,{children:`Foundry (classic)`}),`.`]}),`\n`]}),_jsx(OptimizedImage,{src:`https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=3cbdc91c816894804a08542085e32659`,\"data-og-width\":`184`,width:`184`,\"data-og-height\":`36`,height:`36`,\"data-path\":`images/classic-foundry.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?w=280\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=8cc937ac3a88766e9ae18a999d8c4e71 280w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?w=560\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=7b3196822f921b9e040aaa50a91df913 560w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?w=840\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=2dae762edbc5a97a007a0f29fcd5116c 840w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=c99d7c809bc2f73fe7a89ea447b8fb0e 1100w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=9045824aa3a13c817d45a03f4e23997a 1650w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/classic-foundry.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=bccfed6f0674ac20b5fa6070aa7e7bf9 2500w`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Playgrounds`}),` from the left pane and then select a playground to use. In this example, select `,_jsx(_components.strong,{children:`Try the Speech playground`}),`.`]}),`\n`]}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=3eed3279c93831ffcad790a8e0227644`,alt:`Screenshot of the project level playgrounds that you can use.`,\"data-og-width\":`2279`,width:`2279`,\"data-og-height\":`1009`,height:`1009`,\"data-path\":`images/azure-ai-services-playgrounds.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?w=280\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=d6b1b107cb9f92a2de209a02b2aefce8 280w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?w=560\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=f79f3033be5d1caa92b7ec76d931d4e7 560w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?w=840\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=3e090d9369d3a4b2729b7dd4f1f84483 840w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?w=1100\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=729b8250b7461bc07753c324dc214ece 1100w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?w=1650\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=998b0d5c53bfbdb12fbe95f06b935060 1650w, https://mintcdn.com/hobbyist-e43fa225/i8cG-y5gTtUVot10/images/azure-ai-services-playgrounds.png?w=2500\u0026fit=max\u0026auto=format\u0026n=i8cG-y5gTtUVot10\u0026q=85\u0026s=f2ceb28869481c96c8af4c1bde386988 2500w`})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Select `,_jsx(_components.strong,{children:`Real-time transcription`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Select `,_jsx(_components.strong,{children:`Show advanced options`}),` to configure speech to text options such as:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Language identification`}),`: Used to identify languages spoken in audio when compared against a list of supported languages. For more information about language identification options such as at-start and continuous recognition, see `,_jsx(_components.a,{href:`/language-identification`,children:`Language identification`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Speaker diarization`}),`: Used to identify and separate speakers in audio. Diarization distinguishes between the different speakers who participate in the conversation. The Speech service provides information about which speaker was speaking a particular part of transcribed speech. For more information about speaker diarization, see the `,_jsx(_components.a,{href:`/get-started-stt-diarization`,children:`real-time speech to text with speaker diarization`}),` quickstart.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Custom endpoint`}),`: Use a deployed model from custom speech to improve recognition accuracy. To use Microsoft’s baseline model, leave this set to None. For more information about custom speech, see `,_jsx(_components.a,{href:`/custom-speech-overview`,children:`Custom Speech`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Output format`}),`: Choose between simple and detailed output formats. Simple output includes display format and timestamps. Detailed output includes more formats (such as display, lexical, ITN, and masked ITN), timestamps, and N-best lists.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Phrase list`}),`: Improve transcription accuracy by providing a list of known phrases, such as names of people or specific locations. Use commas or semicolons to separate each value in the phrase list. For more information about phrase lists, see `,_jsx(_components.a,{href:`/improve-accuracy-phrase-list`,children:`Phrase lists`}),`.`]}),`\n`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Select an audio file to upload, or record audio in real-time. In this example, we use the `,_jsx(_components.code,{children:`Call1_separated_16k_health_insurance.wav`}),` file that’s available in the `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/cognitive-services-speech-sdk/raw/master/scenarios/call-center/sampledata/Call1_separated_16k_health_insurance.wav`,children:`Speech SDK repository on GitHub`}),`. You can download the file or use your own audio file.`]}),`\n`]}),`\n`]}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=45b30949cd1fe2fe3e30e8c23f38220f`,alt:`Screenshot of the option to select an audio file or speak into a microphone.`,\"data-og-width\":`2465`,width:`2465`,\"data-og-height\":`680`,height:`680`,\"data-path\":`images/real-time-speech-to-text-audio.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?w=280\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=26b9d5b0a796274c50e9e6823d3e8edc 280w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?w=560\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=9d2af77c736df5fa811af3df2c84e750 560w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?w=840\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=5db3a328c8d9a3568664f96ecc0479a7 840w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?w=1100\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=adf1973f0700816df3dfc7fb751ee8b1 1100w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?w=1650\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=6c3e7b623b98219707f4b5f31317a966 1650w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-audio.png?w=2500\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=334a6eef068615bf28856060483c597d 2500w`})}),_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`You can view the real-time transcription at the bottom of the page.`}),`\n`]}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=8651e47ad03a529e9b285c4ea9382561`,alt:`Screenshot of the real-time transcription results in Microsoft Foundry.`,\"data-og-width\":`3694`,width:`3694`,\"data-og-height\":`1901`,height:`1901`,\"data-path\":`images/real-time-speech-to-text-results.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?w=280\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=eabc49478840424ad7eda80dae45b564 280w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?w=560\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=f30d91ad16b42af763a9dc53b7a5df50 560w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?w=840\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=2552dab586b707e16f5bb5527f604035 840w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?w=1100\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=f25105dbb5444784f69570dbc94a2902 1100w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?w=1650\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=81643d65248f1c2213d00eb64ccefe03 1650w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results.png?w=2500\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=e917919effefe0191b5dbafdca5abcf0 2500w`})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`You can select the `,_jsx(_components.strong,{children:`JSON`}),` tab to see the JSON output of the transcription. Properties include `,_jsx(_components.code,{children:`Offset`}),`, `,_jsx(_components.code,{children:`Duration`}),`, `,_jsx(_components.code,{children:`RecognitionStatus`}),`, `,_jsx(_components.code,{children:`Display`}),`, `,_jsx(_components.code,{children:`Lexical`}),`, `,_jsx(_components.code,{children:`ITN`}),`, and more.`]}),`\n`]}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=022b249ec7ff8af56e6b62983de36993`,alt:`Screenshot of the real-time transcription results in JSON format in Microsoft Foundry.`,\"data-og-width\":`2461`,width:`2461`,\"data-og-height\":`1177`,height:`1177`,\"data-path\":`images/real-time-speech-to-text-results-json.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?w=280\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=ba537210a91a4013665831aaa68b0573 280w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?w=560\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=bf0627488a2129ff8b44f686347fcc18 560w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?w=840\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=817a4b2faf82b78290d9fb28a33a5043 840w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?w=1100\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=f8ea92c4ebbc2a53d6eed1a6e854aebc 1100w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?w=1650\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=fe17f5ddedab25a2bdda727d8d49766e 1650w, https://mintcdn.com/hobbyist-e43fa225/_qpHdwibkfCcXaky/images/real-time-speech-to-text-results-json.png?w=2500\u0026fit=max\u0026auto=format\u0026n=_qpHdwibkfCcXaky\u0026q=85\u0026s=e1493da8030af5e0c3cdf8d6014c3f3e 2500w`})})]})]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-csharp`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://learn.microsoft.com/dotnet/api/microsoft.cognitiveservices.speech`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech`,children:`Package (NuGet)`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-csharp`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-2`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create an AI Services resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and endpoint. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`set-up-the-environment`,children:`Set up the environment`}),_jsxs(_components.p,{children:[`The Speech SDK is available as a `,_jsx(_components.a,{href:`https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech`,children:`NuGet package`}),` and implements .NET Standard 2.0. You install the Speech SDK later in this guide. For any other requirements, see `,_jsx(_components.a,{href:`/quickstarts/setup-platform`,children:`Install the Speech SDK`}),`.`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and endpoint, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.em,{children:`your-endpoint`}),` with one of the endpoints for your resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource endpoint, follow the same steps. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource. For example, `,_jsx(_components.code,{children:`https://YourServiceRegion.api.cognitive.microsoft.com`}),`.`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-microphone`,children:`Recognize speech from a microphone`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`Try out the `,_jsx(_components.a,{href:`https://marketplace.visualstudio.com/items?itemName=ms-azureaispeech.azure-ai-speech-toolkit`,children:`Azure Speech in Foundry Tools Toolkit`}),` to easily build and run samples on Visual Studio Code.`]})}),_jsx(_components.p,{children:`Follow these steps to create a console application and install the Speech SDK.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Open a command prompt window in the folder where you want the new project. Run this command to create a console application with the .NET CLI.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`dotnet new console`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`This command creates the `,_jsx(_components.em,{children:`Program.cs`}),` file in your project directory.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Install the Speech SDK in your new project with the .NET CLI.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`dotnet add package Microsoft.CognitiveServices.Speech`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Replace the contents of `,_jsx(_components.em,{children:`Program.cs`}),` with the following code:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`49`,language:`csharp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`csharp`,children:_jsxs(_components.code,{language:`csharp`,numberOfLines:`49`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.IO;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.Threading.Tasks;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Microsoft.CognitiveServices.Speech;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Microsoft.CognitiveServices.Speech.Audio;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`class`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Program `})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // This example requires environment variables named \"SPEECH_KEY\" and \"ENDPOINT\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechKey = Environment.GetEnvironmentVariable(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` endpoint = Environment.GetEnvironmentVariable(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ENDPOINT\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OutputSpeechRecognitionResult(SpeechRecognitionResult speechRecognitionResult)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` switch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (speechRecognitionResult.Reason)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason.RecognizedSpeech:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine($`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"RECOGNIZED: Text={speechRecognitionResult.Text}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason.NoMatch:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine($`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"NOMATCH: Speech could not be recognized.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason.Canceled:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancellation = CancellationDetails.FromResult(speechRecognitionResult);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine($`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: Reason={cancellation.Reason}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (cancellation.Reason == CancellationReason.Error)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine($`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: ErrorCode={cancellation.ErrorCode}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine($`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: ErrorDetails={cancellation.ErrorDetails}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine($`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: Did you set the speech resource key and endpoint values?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Task Main(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[] args)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig = SpeechConfig.FromEndpoint(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Uri(endpoint), speechKey);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig.SpeechRecognitionLanguage = `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"en-US\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` using`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig = AudioConfig.FromDefaultMicrophoneInput();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` using`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognizer(speechConfig, audioConfig);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Console.WriteLine(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Speak into your microphone.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognitionResult = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.RecognizeOnceAsync();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OutputSpeechRecognitionResult(speechRecognitionResult);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`Language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Run your new console application to start speech recognition from a microphone:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`dotnet run`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`ENDPOINT`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Speak into your microphone when prompted. What you speak should appear as text:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Speak into your microphone.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`RECOGNIZED: Text=I'm excited to try speech to text.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`remarks`,children:`Remarks`}),_jsx(_components.p,{children:`Here are some other considerations:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`RecognizeOnceAsync`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To recognize speech from an audio file, use `,_jsx(_components.code,{children:`FromWavFileInput`}),` instead of `,_jsx(_components.code,{children:`FromDefaultMicrophoneInput`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`csharp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`csharp`,children:_jsxs(_components.code,{language:`csharp`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig = AudioConfig.FromWavFileInput(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YourAudioFile.wav\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`For compressed audio files such as MP4, install GStreamer and use `,_jsx(_components.code,{children:`PullAudioInputStream`}),` or `,_jsx(_components.code,{children:`PushAudioInputStream`}),`. For more information, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-use-codec-compressed-audio-input-streams`,children:`How to use compressed input audio`}),`.`]}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-cpp`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/cpp/cognitive-services/speech/`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech`,children:`Package (NuGet)`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-cpp`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-3`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create an AI Services resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and endpoint. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`set-up-the-environment-2`,children:`Set up the environment`}),_jsxs(_components.p,{children:[`The Speech SDK is available as a `,_jsx(_components.a,{href:`https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech`,children:`NuGet package`}),` and implements .NET Standard 2.0. You install the Speech SDK later in this guide. For other requirements, see `,_jsx(_components.a,{href:`/quickstarts/setup-platform`,children:`Install the Speech SDK`}),`.`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables-2`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and endpoint, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.em,{children:`your-endpoint`}),` with one of the endpoints for your resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-2`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-2`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-2`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource endpoint, follow the same steps. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource. For example, `,_jsx(_components.code,{children:`https://YourServiceRegion.api.cognitive.microsoft.com`}),`.`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-microphone-2`,children:`Recognize speech from a microphone`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`Try out the `,_jsx(_components.a,{href:`https://marketplace.visualstudio.com/items?itemName=ms-azureaispeech.azure-ai-speech-toolkit`,children:`Azure Speech in Foundry Tools Toolkit`}),` to easily build and run samples on Visual Studio Code.`]})}),_jsx(_components.p,{children:`Follow these steps to create a console application and install the Speech SDK.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new C++ console project in `,_jsx(_components.a,{href:`https://visualstudio.microsoft.com/downloads/`,children:`Visual Studio Community`}),` named `,_jsx(_components.code,{children:`SpeechRecognition`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Select `,_jsx(_components.strong,{children:`Tools`}),` > `,_jsx(_components.strong,{children:`Nuget Package Manager`}),` > `,_jsx(_components.strong,{children:`Package Manager Console`}),`. In the `,_jsx(_components.strong,{children:`Package Manager Console`}),`, run this command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`Install-Package Microsoft.CognitiveServices.Speech`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Replace the contents of `,_jsx(_components.code,{children:`SpeechRecognition.cpp`}),` with the following code:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`69`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`69`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#include`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \u003ciostream>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#569CD6`},children:` `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#include`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \u003cstdlib.h>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#include`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \u003cspeechapi_cxx.h>`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` namespace`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Microsoft`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`CognitiveServices`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Speech`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` namespace`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Microsoft`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`CognitiveServices`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Speech`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Audio`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` GetEnvironmentVariable`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // This example requires environment variables named \"SPEECH_KEY\" and \"ENDPOINT\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechKey `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` GetEnvironmentVariable`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` endpoint `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` GetEnvironmentVariable`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ENDPOINT\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(speechKey).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`empty`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`||`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(endpoint).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`empty`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Please set both SPEECH_KEY and ENDPOINT environment variables.\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` -`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` SpeechConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`FromEndpoint`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(endpoint, speechKey);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` speechConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`SetSpeechRecognitionLanguage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"en-US\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` AudioConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`FromDefaultMicrophoneInput`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` SpeechRecognizer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`FromConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(speechConfig, audioConfig);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Speak into your microphone.`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` speechRecognizer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`RecognizeOnceAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Reason`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` ResultReason`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::RecognizedSpeech)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"RECOGNIZED: Text=\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Reason`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` ResultReason`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::NoMatch)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"NOMATCH: Speech could not be recognized.\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Reason`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` ResultReason`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::Canceled)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancellation `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` CancellationDetails`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`FromResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(result);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"CANCELED: Reason=\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`cancellation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Reason`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`cancellation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Reason`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` CancellationReason`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::Error)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"CANCELED: ErrorCode=\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`cancellation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ErrorCode`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"CANCELED: ErrorDetails=\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` cancellation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ErrorDetails`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::cout `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c\u003c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"CANCELED: Did you set the speech resource key and endpoint values?\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` \u003c\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::endl;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` GetEnvironmentVariable`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#if`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defined`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#569CD6`},children:`(`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#569CD6`},children:`_MSC_VER`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#569CD6`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` size_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requiredSize `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getenv_s`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`requiredSize, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`nullptr`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, name);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (requiredSize `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` buffer `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`make_unique`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[]>(requiredSize);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getenv_s`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`requiredSize, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`buffer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(), requiredSize, name);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` buffer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#else`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` value `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` getenv`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(name);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` value `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` value `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#endif`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`Language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To start speech recognition from a microphone, `,_jsx(_components.a,{href:`/cpp/build/vscpp-step-2-build`,children:`Build and run`}),` your new console application.`]}),`\n`]}),`\n`]}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`ENDPOINT`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Speak into your microphone when prompted. What you speak should appear as text:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Speak into your microphone.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`RECOGNIZED: Text=I'm excited to try speech to text.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`remarks-2`,children:`Remarks`}),_jsx(_components.p,{children:`Here are some other considerations:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`RecognizeOnceAsync`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To recognize speech from an audio file, use `,_jsx(_components.code,{children:`FromWavFileInput`}),` instead of `,_jsx(_components.code,{children:`FromDefaultMicrophoneInput`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` AudioConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`FromWavFileInput`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YourAudioFile.wav\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`For compressed audio files such as MP4, install GStreamer and use `,_jsx(_components.code,{children:`PullAudioInputStream`}),` or `,_jsx(_components.code,{children:`PushAudioInputStream`}),`. For more information, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-use-codec-compressed-audio-input-streams`,children:`How to use compressed input audio`}),`.`]}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-2`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-go`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://aka.ms/csspeech/goref`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://pkg.go.dev/github.com/Microsoft/cognitive-services-speech-sdk-go`,children:`Package (Go)`}),` | `,_jsx(_components.a,{href:`https://github.com/microsoft/cognitive-services-speech-sdk-go/tree/master/samples/`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-4`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create a Foundry resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and region. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`set-up-the-environment-3`,children:`Set up the environment`}),_jsxs(_components.p,{children:[`Install the Speech SDK for Go. For requirements and instructions, see `,_jsx(_components.a,{href:`/quickstarts/setup-platform`,children:`Install the Speech SDK`}),`.`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables-3`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and region, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_REGION`}),` environment variable, replace `,_jsx(_components.em,{children:`your-region`}),` with one of the regions for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.code,{children:`your-endpoint`}),` with the actual endpoint of your Speech resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-3`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_REGION your-region`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-3`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-3`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource region, follow the same steps. Set `,_jsx(_components.code,{children:`SPEECH_REGION`}),` to the region of your resource. For example, `,_jsx(_components.code,{children:`westus`}),`. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-microphone-3`,children:`Recognize speech from a microphone`}),_jsx(_components.p,{children:`Follow these steps to create a GO module.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Open a command prompt window in the folder where you want the new project. Create a new file named `,_jsx(_components.em,{children:`speech-recognition.go`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Copy the following code into `,_jsx(_components.em,{children:`speech-recognition.go`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`69`,language:`go`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`go`,children:_jsxs(_components.code,{language:`go`,numberOfLines:`69`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`package`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` main`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"bufio\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"fmt\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"os\"`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"github.com/Microsoft/cognitive-services-speech-sdk-go/audio\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"github.com/Microsoft/cognitive-services-speech-sdk-go/speech\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` sessionStartedHandler(event speech.SessionEventArgs) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.Close()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Session Started (ID=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, event.SessionID, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\")\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` sessionStoppedHandler(event speech.SessionEventArgs) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.Close()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Session Stopped (ID=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, event.SessionID, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\")\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognizingHandler(event speech.SpeechRecognitionEventArgs) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.Close()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Recognizing:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, event.Result.Text)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognizedHandler(event speech.SpeechRecognitionEventArgs) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.Close()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Recognized:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, event.Result.Text)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancelledHandler(event speech.SpeechRecognitionCanceledEventArgs) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.Close()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Received a cancellation: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, event.ErrorDetails)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Did you set the speech resource key and region values?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` main() {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // This example requires environment variables named \"SPEECH_KEY\" and \"SPEECH_REGION\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechKey := os.Getenv(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRegion := os.Getenv(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_REGION\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig, err := audio.NewAudioConfigFromDefaultMicrophoneInput()`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` err != `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`nil`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Got an error: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, err)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig.Close()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig, err := speech.NewSpeechConfigFromSubscription(speechKey, speechRegion)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` err != `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`nil`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Got an error: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, err)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig.Close()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer, err := speech.NewSpeechRecognizerFromConfig(speechConfig, audioConfig)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` err != `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`nil`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fmt.Println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Got an error: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, err)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.Close()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.SessionStarted(sessionStartedHandler)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.SessionStopped(sessionStoppedHandler)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.Recognizing(recognizingHandler)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.Recognized(recognizedHandler)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.Canceled(cancelledHandler)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.StartContinuousRecognitionAsync()`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` defer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.StopContinuousRecognitionAsync()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` bufio.NewReader(os.Stdin).ReadBytes(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'\\\\n'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Run the following commands to create a `,_jsx(_components.em,{children:`go.mod`}),` file that links to components hosted on GitHub:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`vb`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`vb`,children:_jsxs(_components.code,{language:`vb`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`go `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`mod`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` init `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`speech`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`recognition`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`go`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` get `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`github.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`com`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Microsoft`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`/`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`cognitive`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`services`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`speech`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sdk`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`go`})]}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`SPEECH_REGION`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Build and run the code:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`vb`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`vb`,children:_jsxs(_components.code,{language:`vb`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`go build`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`go run `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`speech`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`recognition`})]}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-3`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-java`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://learn.microsoft.com/java/api/com.microsoft.cognitiveservices.speech`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-java`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-5`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create an AI Services resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and endpoint. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`set-up-the-environment-4`,children:`Set up the environment`}),_jsxs(_components.p,{children:[`To set up your environment, `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/quickstarts/setup-platform`,children:`install the Speech SDK`}),`. The sample in this quickstart works with the `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/quickstarts/setup-platform`,children:`Java Runtime`}),`.`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Install `,_jsx(_components.a,{href:`https://maven.apache.org/install.html`,children:`Apache Maven`}),`. Then run `,_jsx(_components.code,{children:`mvn -v`}),` to confirm successful installation.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new `,_jsx(_components.code,{children:`pom.xml`}),` file in the root of your project, and copy the following code into it:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`26`,language:`xml`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`xml`,children:_jsxs(_components.code,{language:`xml`,numberOfLines:`26`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`project`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` xmlns`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http://maven.apache.org/POM/4.0.0\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` xmlns:xsi`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http://www.w3.org/2001/XMLSchema-instance\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` xsi:schemaLocation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`modelVersion`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`4.0.0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`modelVersion`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`com.microsoft.cognitiveservices.speech.samples`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`quickstart-eclipse`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`1.0.0-SNAPSHOT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`sourceDirectory`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`src`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`sourceDirectory`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`plugins`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`plugin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`maven-compiler-plugin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`3.7.0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`configuration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`source`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`1.8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`source`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`target`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`1.8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`target`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`configuration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`plugin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`plugins`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`dependencies`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`com.microsoft.cognitiveservices.speech`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`groupId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client-sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`artifactId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`1.43.0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`version`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`dependency`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`dependencies`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`project`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Install the Speech SDK and dependencies.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`mvn clean dependency:copy-dependencies`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables-4`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and endpoint, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.em,{children:`your-endpoint`}),` with one of the endpoints for your resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-4`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-4`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-4`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource endpoint, follow the same steps. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource. For example, `,_jsx(_components.code,{children:`https://YourServiceRegion.api.cognitive.microsoft.com`}),`.`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-microphone-4`,children:`Recognize speech from a microphone`}),_jsx(_components.p,{children:`Follow these steps to create a console application for speech recognition.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new file named `,_jsx(_components.em,{children:`SpeechRecognition.java`}),` in the same project root directory.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Copy the following code into `,_jsx(_components.em,{children:`SpeechRecognition.java`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`47`,language:`java`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`java`,children:_jsxs(_components.code,{language:`java`,numberOfLines:`47`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` com.microsoft.cognitiveservices.speech.*;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` com.microsoft.cognitiveservices.speech.audio.AudioConfig;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` java.net.URI;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` java.net.URISyntaxException;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` java.util.concurrent.ExecutionException;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` java.util.concurrent.Future;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` class`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognition {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // This example requires environment variables named \"SPEECH_KEY\" and \"ENDPOINT\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` private`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` String speechKey = System.getenv(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` private`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` String endpoint = System.getenv(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ENDPOINT\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` main(String[] args) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`throws`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` InterruptedException, ExecutionException, URISyntaxException {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechConfig speechConfig = SpeechConfig.fromEndpoint(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` URI(endpoint), speechKey);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig.setSpeechRecognitionLanguage(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"en-US\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognizeFromMicrophone(speechConfig);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognizeFromMicrophone(SpeechConfig speechConfig) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`throws`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` InterruptedException, ExecutionException {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AudioConfig audioConfig = AudioConfig.fromDefaultMicrophoneInput();`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognizer speechRecognizer = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognizer(speechConfig, audioConfig);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Speak into your microphone.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Future\u003cSpeechRecognitionResult> task = speechRecognizer.recognizeOnceAsync();`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognitionResult speechRecognitionResult = task.get();`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (speechRecognitionResult.getReason() == ResultReason.RecognizedSpeech) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"RECOGNIZED: Text=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + speechRecognitionResult.getText());`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (speechRecognitionResult.getReason() == ResultReason.NoMatch) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"NOMATCH: Speech could not be recognized.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` else`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (speechRecognitionResult.getReason() == ResultReason.Canceled) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` CancellationDetails cancellation = CancellationDetails.fromResult(speechRecognitionResult);`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: Reason=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + cancellation.getReason());`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (cancellation.getReason() == CancellationReason.Error) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: ErrorCode=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + cancellation.getErrorCode());`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: ErrorDetails=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + cancellation.getErrorDetails());`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.out.println(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: Did you set the speech resource key and endpoint values?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` System.exit(0);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`Language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Run your new console application to start speech recognition from a microphone:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`javac SpeechRecognition.java -cp \".;target\\\\dependency\\\\*\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`java -cp \".;target\\\\dependency\\\\*\" SpeechRecognition`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`ENDPOINT`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Speak into your microphone when prompted. What you speak should appear as text:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Speak into your microphone.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`RECOGNIZED: Text=I'm excited to try speech to text.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`remarks-3`,children:`Remarks`}),_jsx(_components.p,{children:`Here are some other considerations:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`RecognizeOnceAsync`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To recognize speech from an audio file, use `,_jsx(_components.code,{children:`fromWavFileInput`}),` instead of `,_jsx(_components.code,{children:`fromDefaultMicrophoneInput`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`java`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`java`,children:_jsxs(_components.code,{language:`java`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`AudioConfig audioConfig = AudioConfig.fromWavFileInput(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YourAudioFile.wav\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`For compressed audio files such as MP4, install GStreamer and use `,_jsx(_components.code,{children:`PullAudioInputStream`}),` or `,_jsx(_components.code,{children:`PushAudioInputStream`}),`. For more information, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-use-codec-compressed-audio-input-streams`,children:`How to use compressed input audio`}),`.`]}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-4`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-javascript`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://learn.microsoft.com/javascript/api/microsoft-cognitiveservices-speech-sdk/`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://www.npmjs.com/package/microsoft-cognitiveservices-speech-sdk`,children:`Package (npm)`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-javascript`,children:`Additional samples on GitHub`}),` | `,_jsx(_components.a,{href:`https://github.com/Microsoft/cognitive-services-speech-sdk-js`,children:`Library source code`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-6`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create a Foundry resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and region. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.\nYou also need a `,_jsx(_components.em,{children:`.wav`}),` audio file on your local machine. You can use your own `,_jsx(_components.em,{children:`.wav`}),` file (up to 30 seconds) or download the `,_jsx(_components.a,{href:`https://crbn.us/whatstheweatherlike.wav`,children:`https://crbn.us/whatstheweatherlike.wav`}),` sample file.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`setup`,children:`Setup`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new folder `,_jsx(_components.code,{children:`transcription-quickstart`}),` and go to the quickstart folder with the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`mkdir`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` transcription-quickstart \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` transcription-quickstart`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create the `,_jsx(_components.code,{children:`package.json`}),` with the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` init -y`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Install the Speech SDK for JavaScript with:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`npm install microsoft-cognitiveservices-speech-sdk`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`3`,id:`retrieve-resource-information`,children:`Retrieve resource information`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and region, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_REGION`}),` environment variable, replace `,_jsx(_components.em,{children:`your-region`}),` with one of the regions for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.code,{children:`your-endpoint`}),` with the actual endpoint of your Speech resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-5`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_REGION your-region`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-5`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-5`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource region, follow the same steps. Set `,_jsx(_components.code,{children:`SPEECH_REGION`}),` to the region of your resource. For example, `,_jsx(_components.code,{children:`westus`}),`. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-file`,children:`Recognize speech from a file`}),_jsx(_components.p,{children:`To transcribe speech from a file:`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new file named `,_jsx(_components.em,{children:`transcription.js`}),` with the following content:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`38`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`38`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { readFileSync, createReadStream } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"fs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { SpeechConfig, AudioConfig, ConversationTranscriber, AudioInputStream } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"microsoft-cognitiveservices-speech-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// This example requires environment variables named \"ENDPOINT\" and \"SPEECH_KEY\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig = SpeechConfig.fromEndpoint(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` URL(process.env.ENDPOINT), process.env.SPEECH_KEY);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromFile() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` filename = `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"katiesteve.wav\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig = AudioConfig.fromWavFileInput(readFileSync(filename));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ConversationTranscriber(speechConfig, audioConfig);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` pushStream = AudioInputStream.createPushStream();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` createReadStream(filename).on(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'data'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (chunk) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` pushStream.write(chunk.slice());`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }).on(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'end'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` pushStream.close();`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Transcribing from: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + filename);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.sessionStarted = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (s, e) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SessionStarted event\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SessionId:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + e.sessionId);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.sessionStopped = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (s, e) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SessionStopped event\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SessionId:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + e.sessionId);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.stopTranscribingAsync();`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.canceled = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (s, e) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Canceled event\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(e.errorDetails);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.stopTranscribingAsync();`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.transcribed = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (s, e) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"TRANSCRIBED: Text=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + e.result.text + `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\" Speaker ID=\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + e.result.speakerId);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Start conversation transcription`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` conversationTranscriber.startTranscribingAsync(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () { }, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (err) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.trace(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"err - starting transcription: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` + err);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`fromFile();`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`In `,_jsx(_components.em,{children:`transcription.js`}),`, replace `,_jsx(_components.em,{children:`YourAudioFile.wav`}),` with your own `,_jsx(_components.em,{children:`.wav`}),` file. This example only recognizes speech from a `,_jsx(_components.em,{children:`.wav`}),` file. For information about other audio formats, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-use-codec-compressed-audio-input-streams`,children:`How to use compressed input audio`}),`. This example supports up to 30 seconds of audio.`]}),`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`Language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Run your new console application to start speech recognition from a file:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`node transcription.js`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(_components.p,{children:`Wait a few moments to get the response.`}),_jsx(Heading,{level:`2`,id:`output`,children:`Output`}),_jsx(_components.p,{children:`The speech from the audio file should be output as text:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`RECOGNIZED: Text=I'm excited to try speech to text.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(Heading,{level:`2`,id:`remarks-4`,children:`Remarks`}),_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`recognizeOnceAsync`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`Recognizing speech from a microphone is not supported in Node.js. It’s supported only in a browser-based JavaScript environment. For more information, see the `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/AzureSpeechReactSample`,children:`React sample`}),` and the `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/AzureSpeechReactSample/blob/main/src/App.js#L29`,children:`implementation of speech to text from a microphone`}),` on GitHub.`]}),_jsx(_components.p,{children:`The React sample shows design patterns for the exchange and management of authentication tokens. It also shows the capture of audio from a microphone or file for speech to text conversions.`})]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-5`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-python`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://learn.microsoft.com/python/api/azure-cognitiveservices-speech/`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://pypi.org/project/azure-cognitiveservices-speech/`,children:`Package (PyPi)`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-python`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-7`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create an AI Services resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and endpoint. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`set-up-the-environment-5`,children:`Set up the environment`}),_jsxs(_components.p,{children:[`The Speech SDK for Python is available as a `,_jsx(_components.a,{href:`https://pypi.org/project/azure-cognitiveservices-speech/`,children:`Python Package Index (PyPI) module`}),`. The Speech SDK for Python is compatible with Windows, Linux, and macOS.`]}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`For Windows, install the `,_jsx(_components.a,{href:`/cpp/windows/latest-supported-vc-redist`,children:`Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022`}),` for your platform. Installing this package for the first time might require a restart.`]}),`\n`,_jsx(_components.li,{children:`On Linux, you must use the x64 target architecture.`}),`\n`]}),_jsxs(_components.p,{children:[`Install a version of `,_jsx(_components.a,{href:`https://www.python.org/downloads/`,children:`Python from 3.7 or later`}),`. For other requirements, see `,_jsx(_components.a,{href:`/quickstarts/setup-platform`,children:`Install the Speech SDK`}),`.`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables-5`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and endpoint, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.em,{children:`your-endpoint`}),` with one of the endpoints for your resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-6`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-6`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-6`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource endpoint, follow the same steps. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource. For example, `,_jsx(_components.code,{children:`https://YourServiceRegion.api.cognitive.microsoft.com`}),`.`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-microphone-5`,children:`Recognize speech from a microphone`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`Try out the `,_jsx(_components.a,{href:`https://marketplace.visualstudio.com/items?itemName=ms-azureaispeech.azure-ai-speech-toolkit`,children:`Azure Speech in Foundry Tools Toolkit`}),` to easily build and run samples on Visual Studio Code.`]})}),_jsx(_components.p,{children:`Follow these steps to create a console application.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Open a command prompt window in the folder where you want the new project. Create a new file named `,_jsx(_components.em,{children:`speech_recognition.py`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Run this command to install the Speech SDK:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`pip install azure-cognitiveservices-speech`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Copy the following code into `,_jsx(_components.em,{children:`speech_recognition.py`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`27`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`27`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` azure.cognitiveservices.speech `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechsdk`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`def`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` recognize_from_microphone():`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # This example requires environment variables named \"SPEECH_KEY\" and \"ENDPOINT\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Replace with your own subscription key and endpoint, the endpoint is like : \"https://YourServiceRegion.api.cognitive.microsoft.com\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_config = speechsdk.SpeechConfig(subscription=os.environ.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'SPEECH_KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`), endpoint=os.environ.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'ENDPOINT'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_config.speech_recognition_language=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"en-US\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audio_config = speechsdk.audio.AudioConfig(use_default_microphone=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` print(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Speak into your microphone.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_recognition_result = speech_recognizer.recognize_once_async().get()`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_recognition_result.reason == speechsdk.ResultReason.RecognizedSpeech:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` print(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Recognized: {}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.format(speech_recognition_result.text))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` elif`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_recognition_result.reason == speechsdk.ResultReason.NoMatch:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` print(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"No speech could be recognized: {}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.format(speech_recognition_result.no_match_details))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` elif`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speech_recognition_result.reason == speechsdk.ResultReason.Canceled:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancellation_details = speech_recognition_result.cancellation_details`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` print(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Speech Recognition canceled: {}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.format(cancellation_details.reason))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancellation_details.reason == speechsdk.CancellationReason.Error:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` print(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Error details: {}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.format(cancellation_details.error_details))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` print(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Did you set the speech resource key and endpoint values?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`recognize_from_microphone()`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Run your new console application to start speech recognition from a microphone:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`python speech_recognition.py`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`ENDPOINT`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Speak into your microphone when prompted. What you speak should appear as text:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Speak into your microphone.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`RECOGNIZED: Text=I'm excited to try speech to text.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`remarks-5`,children:`Remarks`}),_jsx(_components.p,{children:`Here are some other considerations:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`recognize_once_async`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To recognize speech from an audio file, use `,_jsx(_components.code,{children:`filename`}),` instead of `,_jsx(_components.code,{children:`use_default_microphone`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`audio_config = speechsdk.audio.AudioConfig(filename=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YourAudioFile.wav\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`For compressed audio files such as MP4, install GStreamer and use `,_jsx(_components.code,{children:`PullAudioInputStream`}),` or `,_jsx(_components.code,{children:`PushAudioInputStream`}),`. For more information, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-use-codec-compressed-audio-input-streams`,children:`How to use compressed input audio`}),`.`]}),`\n`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-6`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-swift`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/objectivec/cognitive-services/speech/`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://aka.ms/csspeech/macosbinary`,children:`Package (download)`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-objective-c`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-8`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create a Foundry resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and region. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`set-up-the-environment-6`,children:`Set up the environment`}),_jsx(_components.p,{children:`The Speech SDK for Swift is distributed as a framework bundle. The framework supports both Objective-C and Swift on both iOS and macOS.`}),_jsxs(_components.p,{children:[`The Speech SDK can be used in Xcode projects as a `,_jsx(_components.a,{href:`https://cocoapods.org/`,children:`CocoaPod`}),`, or `,_jsx(_components.a,{href:`https://aka.ms/csspeech/macosbinary`,children:`downloaded directly`}),` and linked manually. This guide uses a CocoaPod. Install the CocoaPod dependency manager as described in its `,_jsx(_components.a,{href:`https://guides.cocoapods.org/using/getting-started.html`,children:`installation instructions`}),`.`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables-6`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and region, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_REGION`}),` environment variable, replace `,_jsx(_components.em,{children:`your-region`}),` with one of the regions for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.code,{children:`your-endpoint`}),` with the actual endpoint of your Speech resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-7`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_REGION your-region`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-7`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-7`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource region, follow the same steps. Set `,_jsx(_components.code,{children:`SPEECH_REGION`}),` to the region of your resource. For example, `,_jsx(_components.code,{children:`westus`}),`. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-microphone-6`,children:`Recognize speech from a microphone`}),_jsx(_components.p,{children:`Follow these steps to recognize speech in a macOS application.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Clone the `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/cognitive-services-speech-sdk`,children:`Azure-Samples/cognitive-services-speech-sdk`}),` repository to get the `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/swift/macos/from-microphone`,children:`Recognize speech from a microphone in Swift on macOS`}),` sample project. The repository also has iOS samples.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Navigate to the directory of the downloaded sample app (`,_jsx(_components.code,{children:`helloworld`}),`) in a terminal.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Run the command `,_jsx(_components.code,{children:`pod install`}),`. This command generates a `,_jsx(_components.code,{children:`helloworld.xcworkspace`}),` Xcode workspace containing both the sample app and the Speech SDK as a dependency.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Open the `,_jsx(_components.code,{children:`helloworld.xcworkspace`}),` workspace in Xcode.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Open the file named `,_jsx(_components.em,{children:`AppDelegate.swift`}),` and locate the `,_jsx(_components.code,{children:`applicationDidFinishLaunching`}),` and `,_jsx(_components.code,{children:`recognizeFromMic`}),` methods as shown here.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`81`,language:`swift`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`swift`,children:_jsxs(_components.code,{language:`swift`,numberOfLines:`81`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Cocoa`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`@NSApplicationMain`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` AppDelegate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`NSObject`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`NSApplicationDelegate `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` label: NSTextField`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromMicButton: NSButton`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` sub: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`String`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` region: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`String`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` @IBOutlet`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` weak`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` window: NSWindow`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` func`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` applicationDidFinishLaunching`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`_`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` aNotification`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: Notification) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"loading\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // load subscription information`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` sub `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ProcessInfo.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`processInfo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`environment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` region `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ProcessInfo.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`processInfo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`environment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_REGION\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` label `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` NSTextField`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`frame`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`NSRect`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`x`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`100`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`y`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`50`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`width`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`height`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` label.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`textColor`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` NSColor.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`black`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` label.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`lineBreakMode`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`byWordWrapping`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` label.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`stringValue`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Recognition Result\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` label.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`isEditable`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`contentView`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`addSubview`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(label)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromMicButton `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` NSButton`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`frame`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`NSRect`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`x`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`100`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`y`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`300`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`width`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`height`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`30`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromMicButton.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`title`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Recognize\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromMicButton.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`target`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromMicButton.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`action`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` #selector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(fromMicButtonClicked)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`contentView`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`addSubview`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(fromMicButton)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` @objc`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` func`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fromMicButtonClicked`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` DispatchQueue.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`global`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`qos`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: .`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`userInitiated`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`recognizeFromMic`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` func`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` recognizeFromMic`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` var`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig: SPXSpeechConfiguration`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` do`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` SPXSpeechConfiguration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`subscription`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: sub, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`region`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: region)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`catch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"error `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`error`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` happened\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` nil`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`speechRecognitionLanguage`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"en-US\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` SPXAudioConfiguration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` reco `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` SPXSpeechRecognizer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`speechConfiguration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: speechConfig`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`audioConfiguration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: audioConfig)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` reco.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`addRecognizingEventHandler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {reco, evt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"intermediate recognition result: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`evt.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ??`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"(no result)\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`updateLabel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: evt.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`color`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: .`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`gray`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` updateLabel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Listening ...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`color`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: .`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`gray`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Listening...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` reco.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`recognizeOnce`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"recognition result: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`result.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ??`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"(no result)\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`, reason: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`result.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`reason`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`rawValue`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` updateLabel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: result.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`color`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: .`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`black`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result.reason `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPXResultReason.recognizedSpeech {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancellationDetails `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` SPXCancellationDetails`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`fromCanceledRecognitionResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: result)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cancelled: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`result.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`reason`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`cancellationDetails.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`errorDetails`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Did you set the speech resource key and region values?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` updateLabel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Error: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`\\\\(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`cancellationDetails.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`errorDetails`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`color`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: .`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`red`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` func`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` updateLabel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`text`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`String`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`color`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: NSColor) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` DispatchQueue.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`label`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`stringValue`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`label`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`textColor`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` color`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`In `,_jsx(_components.em,{children:`AppDelegate.m`}),`, use the `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables that you previously set`}),` for your Speech resource key and region.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`swift`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`swift`,children:_jsxs(_components.code,{language:`swift`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`sub `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ProcessInfo.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`processInfo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`environment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`region `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ProcessInfo.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`processInfo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`environment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SPEECH_REGION\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`Language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`To make the debug output visible, select `,_jsx(_components.strong,{children:`View`}),` > `,_jsx(_components.strong,{children:`Debug Area`}),` > `,_jsx(_components.strong,{children:`Activate Console`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Build and run the example code by selecting `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Run`}),` from the menu or selecting the `,_jsx(_components.strong,{children:`Play`}),` button.`]}),`\n`]}),`\n`]}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`SPEECH_REGION`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsx(_components.p,{children:`After you select the button in the app and say a few words, you should see the text that you spoke on the lower part of the screen. When you run the app for the first time, it prompts you to give the app access to your computer’s microphone.`}),_jsx(Heading,{level:`2`,id:`remarks-6`,children:`Remarks`}),_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`recognizeOnce`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),_jsx(Heading,{level:`2`,id:`objective-c`,children:`Objective-C`}),_jsxs(_components.p,{children:[`The Speech SDK for Objective-C shares client libraries and reference documentation with the Speech SDK for Swift. For Objective-C code examples, see the `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/objectivec/macos/from-microphone`,children:`recognize speech from a microphone in Objective-C on macOS`}),` sample project in GitHub.`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-7`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-typescript`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`https://learn.microsoft.com/javascript/api/microsoft-cognitiveservices-speech-sdk/`,children:`Reference documentation`}),` | `,_jsx(_components.a,{href:`https://www.npmjs.com/package/microsoft-cognitiveservices-speech-sdk`,children:`Package (npm)`}),` | `,_jsx(_components.a,{href:`https://aka.ms/speech/github-javascript`,children:`Additional samples on GitHub`}),` | `,_jsx(_components.a,{href:`https://github.com/Microsoft/cognitive-services-speech-sdk-js`,children:`Library source code`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-9`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create a Foundry resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and region. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.\nYou also need a `,_jsx(_components.em,{children:`.wav`}),` audio file on your local machine. You can use your own `,_jsx(_components.em,{children:`.wav`}),` file (up to 30 seconds) or download the `,_jsx(_components.a,{href:`https://crbn.us/whatstheweatherlike.wav`,children:`https://crbn.us/whatstheweatherlike.wav`}),` sample file.`]}),`\n`]}),_jsx(Heading,{level:`2`,id:`setup-2`,children:`Setup`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new folder `,_jsx(_components.code,{children:`transcription-quickstart`}),` and go to the quickstart folder with the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`mkdir`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` transcription-quickstart \u0026\u0026 `}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`cd`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` transcription-quickstart`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create the `,_jsx(_components.code,{children:`package.json`}),` with the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` init -y`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Update the `,_jsx(_components.code,{children:`package.json`}),` to ECMAScript with the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` pkg set type=module`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Install the Speech SDK for JavaScript with:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`npm install microsoft-cognitiveservices-speech-sdk`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`You need to install the Node.js type definitions to avoid TypeScript errors. Run the following command:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` install --save-dev @types/node`})]}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(Heading,{level:`3`,id:`retrieve-resource-information-2`,children:`Retrieve resource information`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and region, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_REGION`}),` environment variable, replace `,_jsx(_components.em,{children:`your-region`}),` with one of the regions for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.code,{children:`your-endpoint`}),` with the actual endpoint of your Speech resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-8`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_REGION your-region`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-8`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-8`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource region, follow the same steps. Set `,_jsx(_components.code,{children:`SPEECH_REGION`}),` to the region of your resource. For example, `,_jsx(_components.code,{children:`westus`}),`. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-file-2`,children:`Recognize speech from a file`}),_jsx(_components.p,{children:`To transcribe speech from a file:`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create a new file named `,_jsx(_components.em,{children:`transcription.ts`}),` with the following content:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`43`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`43`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { readFileSync } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"fs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechConfig, `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AudioConfig, `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognizer, `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason, `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` CancellationDetails, `})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` CancellationReason,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognitionResult `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"microsoft-cognitiveservices-speech-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// This example requires environment variables named \"ENDPOINT\" and \"SPEECH_KEY\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechConfig: SpeechConfig = SpeechConfig.fromEndpoint(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` URL(process.env.ENDPOINT!), process.env.SPEECH_KEY!);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`speechConfig.speechRecognitionLanguage = `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"en-US\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fromFile(): `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audioConfig: AudioConfig = AudioConfig.fromWavFileInput(readFileSync(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YourAudioFile.wav\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer: SpeechRecognizer = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`new`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SpeechRecognizer(speechConfig, audioConfig);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.recognizeOnceAsync((result: SpeechRecognitionResult) => {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` switch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (result.reason) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason.RecognizedSpeech:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`RECOGNIZED: Text=${result.text}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason.NoMatch:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"NOMATCH: Speech could not be recognized.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` case`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ResultReason.Canceled:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` cancellation: CancellationDetails = CancellationDetails.fromResult(result);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`CANCELED: Reason=${cancellation.reason}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (cancellation.reason === CancellationReason.Error) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`CANCELED: ErrorCode=${cancellation.ErrorCode}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`CANCELED: ErrorDetails=${cancellation.errorDetails}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` console.log(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"CANCELED: Did you set the speech resource key and region values?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` speechRecognizer.close();`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`fromFile();`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`In `,_jsx(_components.em,{children:`transcription.ts`}),`, replace `,_jsx(_components.em,{children:`YourAudioFile.wav`}),` with your own `,_jsx(_components.em,{children:`.wav`}),` file. This example only recognizes speech from a `,_jsx(_components.em,{children:`.wav`}),` file. For information about other audio formats, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-use-codec-compressed-audio-input-streams`,children:`How to use compressed input audio`}),`. This example supports up to 30 seconds of audio.`]}),`\n`,_jsxs(_components.p,{children:[`To change the speech recognition language, replace `,_jsx(_components.code,{children:`en-US`}),` with another `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-support`,children:`supported language`}),`. For example, use `,_jsx(_components.code,{children:`es-ES`}),` for Spanish (Spain). If you don’t specify a language, the default is `,_jsx(_components.code,{children:`en-US`}),`. For details about how to identify one of multiple languages that might be spoken, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/language-identification`,children:`Language identification`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create the `,_jsx(_components.code,{children:`tsconfig.json`}),` file to transpile the TypeScript code and copy the following code for ECMAScript.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`10`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"compilerOptions\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"module\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"NodeNext\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"target\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ES2022\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Supports top-level await`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"moduleResolution\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"NodeNext\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"skipLibCheck\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Avoid type errors from node_modules`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"strict\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Enable strict type-checking options`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"include\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"*.ts\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Transpile from TypeScript to JavaScript.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`tsc`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This command should produce no output if successful.`}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Run your new console application to start speech recognition from a file:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`1`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`node transcription.js`})}),`\n`]})})}),`\n`]}),`\n`]}),_jsx(_components.p,{children:`Wait a few moments to get the response.`}),_jsx(Heading,{level:`2`,id:`output-2`,children:`Output`}),_jsx(_components.p,{children:`The speech from the audio file should be output as text:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`RECOGNIZED: Text=I'm excited to try speech to text.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(Heading,{level:`2`,id:`remarks-7`,children:`Remarks`}),_jsxs(_components.p,{children:[`This example uses the `,_jsx(_components.code,{children:`recognizeOnceAsync`}),` operation to transcribe utterances of up to 30 seconds, or until silence is detected. For information about continuous recognition for longer audio, including multi-lingual conversations, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/how-to-recognize-speech`,children:`How to recognize speech`}),`.`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-8`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})}),`\n`,_jsx(_MdxComponentBoundary,{name:`ZoneContent`,children:_jsxs(ZoneContent,{group:`ai-foundry__programming-language-cpp__programming-language-csharp__programming-language-go__programming-language-java__programming-language-javascript__programming-language-python__programming-language-rest__programming-language-swift__programming-language-typescript`,value:`programming-language-rest`,options:[{\"id\":`ai-foundry`,\"title\":`Foundry portal`},{\"id\":`programming-language-csharp`,\"title\":`C#`},{\"id\":`programming-language-cpp`,\"title\":`C++`},{\"id\":`programming-language-go`,\"title\":`Go`},{\"id\":`programming-language-java`,\"title\":`Java`},{\"id\":`programming-language-javascript`,\"title\":`JavaScript`},{\"id\":`programming-language-python`,\"title\":`Python`},{\"id\":`programming-language-swift`,\"title\":`Swift`},{\"id\":`programming-language-typescript`,\"title\":`TypeScript`},{\"id\":`programming-language-rest`,\"title\":`REST`}],values:[`ai-foundry`,`programming-language-csharp`,`programming-language-cpp`,`programming-language-go`,`programming-language-java`,`programming-language-javascript`,`programming-language-python`,`programming-language-swift`,`programming-language-typescript`,`programming-language-rest`],defaultValue:`ai-foundry`,children:[_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/rest-speech-to-text`,children:`Speech to text REST API reference`}),` | `,_jsx(_components.a,{href:`/rest-speech-to-text-short`,children:`Speech to text REST API for short audio reference`}),` | `,_jsx(_components.a,{href:`https://github.com/Azure-Samples/cognitive-services-speech-sdk`,children:`Additional samples on GitHub`})]}),_jsx(_components.p,{children:`In this quickstart, you create and run an application to recognize and transcribe speech to text in real-time.`}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`For fast transcription of audio files, consider using the `,_jsx(_components.a,{href:`https://learn.microsoft.com/azure/ai-services/speech-service/fast-transcription-create`,children:`fast transcription API.`}),` Fast transcription API supports features such as language identification and diarization.`]})}),_jsxs(_components.p,{children:[`To instead transcribe audio files asynchronously, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/batch-transcription`,children:`What is batch transcription`}),`. If you’re not sure which speech to text solution is right for you, see `,_jsx(_components.a,{href:`~/articles/ai-services/speech-service/speech-to-text`,children:`What is speech to text?`})]}),_jsx(Heading,{level:`2`,id:`prerequisites-10`,children:`Prerequisites`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`An Azure subscription. You can `,_jsx(_components.a,{href:`https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn`,children:`create one for free`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://portal.azure.com/#create/Microsoft.CognitiveServicesAIFoundry`,children:`Create a Foundry resource for Speech`}),` in the Azure portal.`]}),`\n`,_jsxs(_components.li,{children:[`Get the Speech resource key and region. After your Speech resource is deployed, select `,_jsx(_components.strong,{children:`Go to resource`}),` to view and manage keys.\nYou also need a `,_jsx(_components.em,{children:`.wav`}),` audio file on your local machine. You can use your own `,_jsx(_components.em,{children:`.wav`}),` file up to 60 seconds or download the `,_jsx(_components.a,{href:`https://crbn.us/whatstheweatherlike.wav`,children:`https://crbn.us/whatstheweatherlike.wav`}),` sample file.`]}),`\n`]}),_jsx(Heading,{level:`3`,id:`set-environment-variables-7`,children:`Set environment variables`}),_jsx(_components.p,{children:`You need to authenticate your application to access Foundry Tools. This article shows you how to use environment variables to store your credentials. You can then access the environment variables from your code to authenticate your application. For production, use a more secure way to store and access your credentials.`}),_jsx(_components.p,{children:`To set the environment variables for your Speech resource key and region, open a console window, and follow the instructions for your operating system and development environment.`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` environment variable, replace `,_jsx(_components.em,{children:`your-key`}),` with one of the keys for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`SPEECH_REGION`}),` environment variable, replace `,_jsx(_components.em,{children:`your-region`}),` with one of the regions for your resource.`]}),`\n`,_jsxs(_components.li,{children:[`To set the `,_jsx(_components.code,{children:`ENDPOINT`}),` environment variable, replace `,_jsx(_components.code,{children:`your-endpoint`}),` with the actual endpoint of your Speech resource.`]}),`\n`]}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`Windows`,id:`windows-9`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellsession`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellsession`,children:_jsxs(_components.code,{language:`shellsession`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_KEY your-key`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx SPEECH_REGION your-region`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`setx ENDPOINT your-endpoint`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`If you only need to access the environment variables in the current console, you can set the environment variable with `,_jsx(_components.code,{children:`set`}),` instead of `,_jsx(_components.code,{children:`setx`}),`.`]})}),_jsx(_components.p,{children:`After you add the environment variables, you might need to restart any programs that need to read the environment variables, including the console window. For example, if you’re using Visual Studio as your editor, restart Visual Studio before you run the example.`})]}),_jsxs(Tab,{title:`Linux`,id:`linux-9`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bashrc`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bashrc`}),` from your console window to make the changes effective.`]})]}),_jsxs(Tab,{title:`macOS`,id:`macos-9`,children:[_jsx(_components.h5,{children:`Bash`}),_jsxs(_components.p,{children:[`Edit your `,_jsx(_components.em,{children:`.bash_profile`}),` file, and add the environment variables:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_KEY=your-key`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SPEECH_REGION=your-region`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ENDPOINT=your-endpoint`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`After you add the environment variables, run `,_jsx(_components.code,{children:`source ~/.bash_profile`}),` from your console window to make the changes effective.`]}),_jsx(_components.h5,{children:`Xcode`}),_jsx(_components.p,{children:`For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.`}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Product`}),` > `,_jsx(_components.strong,{children:`Scheme`}),` > `,_jsx(_components.strong,{children:`Edit scheme`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Select `,_jsx(_components.strong,{children:`Arguments`}),` on the `,_jsx(_components.strong,{children:`Run`}),` (Debug Run) page.`]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Environment Variables`}),` select the plus (+) sign to add a new environment variable.`]}),`\n`,_jsxs(_components.li,{children:[`Enter `,_jsx(_components.code,{children:`SPEECH_KEY`}),` for the `,_jsx(_components.strong,{children:`Name`}),` and enter your Speech resource key for the `,_jsx(_components.strong,{children:`Value`}),`.`]}),`\n`]}),_jsxs(_components.p,{children:[`To set the environment variable for your Speech resource region, follow the same steps. Set `,_jsx(_components.code,{children:`SPEECH_REGION`}),` to the region of your resource. For example, `,_jsx(_components.code,{children:`westus`}),`. Set `,_jsx(_components.code,{children:`ENDPOINT`}),` to the endpoint of your resource`]}),_jsxs(_components.p,{children:[`For more configuration options, see `,_jsx(_components.a,{href:`https://help.apple.com/xcode/#/dev745c5c974`,children:`the Xcode documentation`}),`.`]})]})]}),_jsx(Heading,{level:`2`,id:`recognize-speech-from-a-file-3`,children:`Recognize speech from a file`}),_jsxs(_components.p,{children:[`Open a console window and run the following cURL command. Replace `,_jsx(_components.em,{children:`YourAudioFile.wav`}),` with the path and name of your audio file.`]}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`Windows`,id:`windows-10`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`curl --location --request POST \"https://%SPEECH_REGION%.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US\u0026format=detailed\" ^`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--header \"Ocp-Apim-Subscription-Key: %SPEECH_KEY%\" ^`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--header \"Content-Type: audio/wav\" ^`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--data-binary \"@YourAudioFile.wav\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsx(Tab,{title:`Linux`,id:`linux-10`,children:_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`audio_file=@'YourAudioFile.wav'`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`curl --location --request POST \\\\`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:'\"https://${SPEECH_REGION}.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US\u0026format=detailed\" \\\\'})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:'--header \"Ocp-Apim-Subscription-Key: ${SPEECH_KEY}\" \\\\'})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--header \"Content-Type: audio/wav\" \\\\`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--data-binary $audio_file`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})})}),_jsxs(Tab,{title:`macOS`,id:`macos-10`,\"data-child-heading-ids\":`[\"clean-up-resources-9\"]`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`audio_file=@'YourAudioFile.wav'`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`curl --location --request POST \\\\`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:'\"https://${SPEECH_REGION}.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US\u0026format=detailed\" \\\\'})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:'--header \"Ocp-Apim-Subscription-Key: ${SPEECH_KEY}\" \\\\'})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--header \"Content-Type: audio/wav\" \\\\`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`--data-binary $audio_file`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(_components.hr,{}),_jsx(Info,{children:_jsxs(_components.p,{children:[`Make sure that you set the `,_jsx(_components.code,{children:`SPEECH_KEY`}),` and `,_jsx(_components.code,{children:`SPEECH_REGION`}),` `,_jsx(_components.a,{href:`#set-environment-variables`,children:`environment variables`}),`. If you don’t set these variables, the sample fails with an error message.`]})}),_jsxs(_components.p,{children:[`You should receive a response similar to what is shown here. The `,_jsx(_components.code,{children:`DisplayText`}),` should be the text that was recognized from your audio file. The command recognizes up to 60 seconds of audio and converts it to text.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` \"RecognitionStatus\": \"Success\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` \"DisplayText\": \"My voice is my passport, verify me.\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` \"Offset\": 6600000,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` \"Duration\": 32100000`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(_components.p,{children:[`For more information, see `,_jsx(_components.a,{href:`/rest-speech-to-text-short`,children:`Speech to text REST API for short audio`}),`.`]}),_jsx(Heading,{level:`2`,id:`clean-up-resources-9`,children:`Clean up resources`}),_jsxs(_components.p,{children:[`You can use the `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure portal`}),` or `,_jsx(_components.a,{href:`~/articles/ai-services/multi-service-resource`,children:`Azure Command Line Interface (CLI)`}),` to remove the Speech resource you created.`]})]})]})]})}),`\n`,_jsx(Heading,{level:`2`,id:`next-step`,children:`Next step`}),`\n`,_jsx(Card,{title:`Learn more about speech recognition`,icon:`arrow-right`,href:`how-to-recognize-speech.md`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{ZonePivot,ZoneContent,default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Speech to text quickstart","description":"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.","sidebarTitle":"Speech to text quickstart","href":"/models/get-started-speech-to-text"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[145,5233,")=>null;const ZoneContent=()=>null;funct"]]},"mdxExtracts":{"tableOfContents":[{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Try real-time speech to text","slug":"try-real-time-speech-to-text","depth":2,"children":[]},{"title":"Other Foundry (new) features","slug":"other-foundry-new-features","depth":2,"children":[],"tabId":"foundry-new-portal"},{"title":"Prerequisites","slug":"prerequisites-2","depth":2,"children":[]},{"title":"Set up the environment","slug":"set-up-the-environment","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables","depth":3,"children":[]}]},{"title":"Recognize speech from a microphone","slug":"recognize-speech-from-a-microphone","depth":2,"children":[]},{"title":"Remarks","slug":"remarks","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-3","depth":2,"children":[]},{"title":"Set up the environment","slug":"set-up-the-environment-2","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables-2","depth":3,"children":[]}]},{"title":"Recognize speech from a microphone","slug":"recognize-speech-from-a-microphone-2","depth":2,"children":[]},{"title":"Remarks","slug":"remarks-2","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-2","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-4","depth":2,"children":[]},{"title":"Set up the environment","slug":"set-up-the-environment-3","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables-3","depth":3,"children":[]}]},{"title":"Recognize speech from a microphone","slug":"recognize-speech-from-a-microphone-3","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-3","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-5","depth":2,"children":[]},{"title":"Set up the environment","slug":"set-up-the-environment-4","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables-4","depth":3,"children":[]}]},{"title":"Recognize speech from a microphone","slug":"recognize-speech-from-a-microphone-4","depth":2,"children":[]},{"title":"Remarks","slug":"remarks-3","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-4","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-6","depth":2,"children":[]},{"title":"Setup","slug":"setup","depth":2,"children":[{"title":"Retrieve resource information","slug":"retrieve-resource-information","depth":3,"children":[]}]},{"title":"Recognize speech from a file","slug":"recognize-speech-from-a-file","depth":2,"children":[]},{"title":"Output","slug":"output","depth":2,"children":[]},{"title":"Remarks","slug":"remarks-4","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-5","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-7","depth":2,"children":[]},{"title":"Set up the environment","slug":"set-up-the-environment-5","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables-5","depth":3,"children":[]}]},{"title":"Recognize speech from a microphone","slug":"recognize-speech-from-a-microphone-5","depth":2,"children":[]},{"title":"Remarks","slug":"remarks-5","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-6","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-8","depth":2,"children":[]},{"title":"Set up the environment","slug":"set-up-the-environment-6","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables-6","depth":3,"children":[]}]},{"title":"Recognize speech from a microphone","slug":"recognize-speech-from-a-microphone-6","depth":2,"children":[]},{"title":"Remarks","slug":"remarks-6","depth":2,"children":[]},{"title":"Objective-C","slug":"objective-c","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-7","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-9","depth":2,"children":[]},{"title":"Setup","slug":"setup-2","depth":2,"children":[{"title":"Retrieve resource information","slug":"retrieve-resource-information-2","depth":3,"children":[]}]},{"title":"Recognize speech from a file","slug":"recognize-speech-from-a-file-2","depth":2,"children":[]},{"title":"Output","slug":"output-2","depth":2,"children":[]},{"title":"Remarks","slug":"remarks-7","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-8","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites-10","depth":2,"children":[{"title":"Set environment variables","slug":"set-environment-variables-7","depth":3,"children":[]}]},{"title":"Recognize speech from a file","slug":"recognize-speech-from-a-file-3","depth":2,"children":[]},{"title":"Clean up resources","slug":"clean-up-resources-9","depth":2,"children":[],"tabId":"macos-10"},{"title":"Next step","slug":"next-step","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"dynamicCss":".mint-my-6 {\n margin-top: 1.5rem;\n margin-bottom: 1.5rem\n}\n.mint-mb-2 {\n margin-bottom: 0.5rem\n}\n.mint-flex {\n display: flex\n}\n.mint-flex-wrap {\n flex-wrap: wrap\n}\n.mint-gap-2 {\n gap: 0.5rem\n}\n.mint-rounded-md {\n border-radius: 0.375rem\n}\n.mint-border {\n border-width: 1px\n}\n.mint-border-b {\n border-bottom-width: 1px\n}\n.mint-border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1))\n}\n.mint-border-slate-900 {\n --tw-border-opacity: 1;\n border-color: rgb(15 23 42 / var(--tw-border-opacity, 1))\n}\n.mint-bg-slate-900 {\n --tw-bg-opacity: 1;\n background-color: rgb(15 23 42 / var(--tw-bg-opacity, 1))\n}\n.mint-bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1))\n}\n.mint-px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem\n}\n.mint-py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem\n}\n.mint-pb-3 {\n padding-bottom: 0.75rem\n}\n.mint-text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem\n}\n.mint-text-xs {\n font-size: 0.75rem;\n line-height: 1rem\n}\n.mint-font-medium {\n font-weight: 500\n}\n.mint-font-semibold {\n font-weight: 600\n}\n.mint-uppercase {\n text-transform: uppercase\n}\n.mint-tracking-wide {\n letter-spacing: 0.025em\n}\n.mint-text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1))\n}\n.mint-text-slate-700 {\n --tw-text-opacity: 1;\n color: rgb(51 65 85 / var(--tw-text-opacity, 1))\n}\n.mint-text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1))\n}\n.mint-shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.mint-transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.hover\\:mint-border-slate-400:hover {\n --tw-border-opacity: 1;\n border-color: rgb(148 163 184 / var(--tw-border-opacity, 1))\n}\n.hover\\:mint-text-slate-950:hover {\n --tw-text-opacity: 1;\n color: rgb(2 6 23 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-border-slate-100:is(.dark *) {\n --tw-border-opacity: 1;\n border-color: rgb(241 245 249 / var(--tw-border-opacity, 1))\n}\n.dark\\:mint-border-slate-700:is(.dark *) {\n --tw-border-opacity: 1;\n border-color: rgb(51 65 85 / var(--tw-border-opacity, 1))\n}\n.dark\\:mint-border-slate-800:is(.dark *) {\n --tw-border-opacity: 1;\n border-color: rgb(30 41 59 / var(--tw-border-opacity, 1))\n}\n.dark\\:mint-bg-slate-100:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(241 245 249 / var(--tw-bg-opacity, 1))\n}\n.dark\\:mint-bg-slate-950:is(.dark *) {\n --tw-bg-opacity: 1;\n background-color: rgb(2 6 23 / var(--tw-bg-opacity, 1))\n}\n.dark\\:mint-text-slate-200:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(226 232 240 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-slate-400:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1))\n}\n.dark\\:mint-text-slate-950:is(.dark *) {\n --tw-text-opacity: 1;\n color: rgb(2 6 23 / var(--tw-text-opacity, 1))\n}\n.dark\\:hover\\:mint-border-slate-500:hover:is(.dark *) {\n --tw-border-opacity: 1;\n border-color: rgb(100 116 139 / var(--tw-border-opacity, 1))\n}","subdomain":"hobbyist-e43fa225","siteName":"Microsoft Foundry Docs","title":"Speech to text quickstart - Microsoft Foundry Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-07-08T16:36:53.060Z","originalFileLocation":"models/get-started-speech-to-text.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Microsoft Foundry Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/hobbyist-e43fa225/images/favicon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/hobbyist-e43fa225/images/favicon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/hobbyist-e43fa225/images/favicon.png\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/png\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/hobbyist-e43fa225/images/favicon.png\">\u003cmeta data-mint-head property=\"og:title\" content=\"Speech to text quickstart - Microsoft Foundry Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Microsoft Foundry Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://hobbyist-e43fa225.mintlify.site/_mintlify/api/og/v2?division=Audio+and+speech\u0026amp;title=Speech+to+text+quickstart\u0026amp;description=In+this+quickstart%2C+learn+how+to+use+the+Speech+service+for+real-time+speech+to+text+conversion.\u0026amp;theme=e49a626887a18a2f133fedd5\u0026amp;signature=20cb8de1fd616555902f9c7b609906e56ac63c4f7e4e7d6e83625cfe0a09d04e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Speech to text quickstart - Microsoft Foundry Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://hobbyist-e43fa225.mintlify.site/_mintlify/api/og/v2?division=Audio+and+speech\u0026amp;title=Speech+to+text+quickstart\u0026amp;description=In+this+quickstart%2C+learn+how+to+use+the+Speech+service+for+real-time+speech+to+text+conversion.\u0026amp;theme=e49a626887a18a2f133fedd5\u0026amp;signature=20cb8de1fd616555902f9c7b609906e56ac63c4f7e4e7d6e83625cfe0a09d04e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"https://mintlify.s3.us-west-1.amazonaws.com/hobbyist-e43fa225/_generated/favicon/browserconfig.xml?v=3\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Microsoft Foundry Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0078D4\">\u003clink data-mint-head rel=\"canonical\" href=\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/models/get-started-speech-to-text.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://hobbyist-e43fa225.mintlify.app/#organization\",\"name\":\"Microsoft Foundry Docs\",\"url\":\"https://hobbyist-e43fa225.mintlify.app\"},{\"@type\":\"WebSite\",\"@id\":\"https://hobbyist-e43fa225.mintlify.app#website\",\"name\":\"Microsoft Foundry Docs\",\"url\":\"https://hobbyist-e43fa225.mintlify.app\",\"publisher\":{\"@id\":\"https://hobbyist-e43fa225.mintlify.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text#webpage\",\"url\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text\",\"name\":\"Speech to text quickstart\",\"description\":\"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.\",\"dateModified\":\"2026-07-08T16:36:53.060Z\",\"isPartOf\":{\"@id\":\"https://hobbyist-e43fa225.mintlify.app#website\"},\"breadcrumb\":{\"@id\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Models\",\"item\":\"https://hobbyist-e43fa225.mintlify.app/models/foundry-models-overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Model capabilities\",\"item\":\"https://hobbyist-e43fa225.mintlify.app/models/dall-e\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Audio and speech\",\"item\":\"https://hobbyist-e43fa225.mintlify.app/models/audio-completions-quickstart\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Speech to text quickstart\",\"item\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text#article\",\"headline\":\"Speech to text quickstart\",\"name\":\"Speech to text quickstart\",\"description\":\"In this quickstart, learn how to use the Speech service for real-time speech to text conversion.\",\"url\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text\",\"mainEntityOfPage\":{\"@id\":\"https://hobbyist-e43fa225.mintlify.app/models/get-started-speech-to-text#webpage\"},\"dateModified\":\"2026-07-08T16:36:53.060Z\",\"publisher\":{\"@id\":\"https://hobbyist-e43fa225.mintlify.app/#organization\"},\"isPartOf\":{\"@id\":\"https://hobbyist-e43fa225.mintlify.app#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Microsoft Foundry Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Microsoft Foundry Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/models/get-started-speech-to-text.md","siteName":"Microsoft Foundry Docs","nav":{"global":null,"tabs":[{"tab":"Documentation","groups":[{"group":"What is Microsoft Foundry?","pages":[{"title":"What is Microsoft Foundry?","href":"/what-is-microsoft-foundry/what-is-foundry"}]},{"group":"Product and capability map","pages":[{"title":"Microsoft Foundry product and capability map","href":"/product-and-capability-map/capabilities"}]},{"group":"Capability reference","pages":[{"title":"Microsoft Foundry capability reference","href":"/capability-reference/capability-reference"}]},{"group":"Get started","pages":[{"title":"Microsoft Foundry quickstarts","href":"/get-started/quickstarts"},{"title":"Quickstart: Set up Microsoft Foundry resources","href":"/get-started/quickstart-create-foundry-resources"},{"title":"Tutorial: Idea to prototype - Build and evaluate an enterprise agent","href":"/get-started/developer-journey-idea-to-prototype"},{"group":"What do you want to build?","pages":[{"title":"Quickstart: Create a prompt agent","href":"/get-started/prompt-agent"},{"title":"Quickstart: Create a voice-based prompt agent","href":"/get-started/prompt-voice-agent"},{"title":"Quickstart: Get started with Microsoft Foundry SDK","href":"/get-started/get-started-code"},{"title":"Deploy a hosted agent from source code","href":"/get-started/deploy-hosted-agent-code"},{"title":"Use the Microsoft Foundry Skill in coding agents","href":"/get-started/use-microsoft-foundry-skill"},{"title":"What is Toolbox in Microsoft Foundry?","href":"/get-started/toolbox-overview"},{"title":"How to get started with an AI template","href":"/get-started/ai-template-get-started"}]},{"group":"Explore and migrate","pages":[{"title":"Migrate from the Foundry (classic) portal","href":"/get-started/navigate-from-classic"}]}]},{"group":"Developer tools and integrations","pages":[{"title":"Prepare your development environment","href":"/developer-tools-and-integrations/install-cli-sdk"},{"title":"Microsoft Foundry Playgrounds","href":"/developer-tools-and-integrations/concept-playgrounds"},{"title":"FAQ","href":"/developer-tools-and-integrations/toc"},{"group":"Azure Developer CLI","pages":[{"title":"Agent development with the Azure Developer CLI","href":"/developer-tools-and-integrations/cli-agent-development"},{"title":"Install the Azure Developer CLI Foundry extensions","href":"/developer-tools-and-integrations/install-cli-foundry-extensions"},{"title":"Set the Foundry project context for azd commands","href":"/developer-tools-and-integrations/cli-project-context"}]},{"group":"Foundry Toolkit for Visual Studio Code","pages":[{"title":"Microsoft Foundry Toolkit for Visual Studio Code overview","href":"/developer-tools-and-integrations/get-started-projects-visual-studio-code"},{"title":"Install Microsoft Foundry Toolkit for Visual Studio Code","href":"/developer-tools-and-integrations/install-foundry-toolkit-visual-studio-code"},{"title":"Set up a Microsoft Foundry project in Visual Studio Code","href":"/developer-tools-and-integrations/set-up-foundry-project-visual-studio-code"},{"title":"Create an agent with Microsoft Foundry Toolkit for Visual Studio Code","href":"/developer-tools-and-integrations/create-agent-visual-studio-code"},{"title":"Create a prompt agent with Microsoft Foundry Toolkit for Visual Studio Code","href":"/developer-tools-and-integrations/create-prompt-agent-visual-studio-code"},{"title":"Create hosted agents with Microsoft Foundry Toolkit for Visual Studio Code","href":"/developer-tools-and-integrations/vs-code-agents-workflow-pro-code"},{"title":"Use and migrate declarative agent workflows with Microsoft Foundry Toolkit","href":"/developer-tools-and-integrations/vs-code-agents-workflow-low-code"}]},{"group":"Coding agents","pages":[{"title":"Microsoft Foundry Skill example prompts and scenarios","href":"/developer-tools-and-integrations/foundry-skills-scenarios-example-prompts"},{"title":"Use azd ai with coding agents and scripts","href":"/developer-tools-and-integrations/use-cli-with-coding-agents"},{"title":"What is the Foundry Agent Canvas?","href":"/developer-tools-and-integrations/foundry-agent-canvas"},{"title":"Configure Claude Code for Microsoft Foundry","href":"/developer-tools-and-integrations/configure-claude-code"},{"title":"Configure Claude Desktop for Microsoft Foundry","href":"/developer-tools-and-integrations/configure-claude-desktop"}]},{"group":"Develop with LangChain and LangGraph","pages":[{"title":"Get started with LangChain and LangGraph with Foundry","href":"/developer-tools-and-integrations/langchain"},{"title":"Use LangChain with models in Microsoft Foundry","href":"/developer-tools-and-integrations/langchain-models"},{"title":"Use Foundry Content Safety middleware with LangChain","href":"/developer-tools-and-integrations/langchain-middleware"},{"title":"Use LangGraph with the Agent Service","href":"/developer-tools-and-integrations/langchain-agents"},{"title":"Use Foundry Toolbox with LangChain","href":"/developer-tools-and-integrations/langchain-toolbox"},{"title":"Host LangGraph agents as Foundry hosted agents","href":"/developer-tools-and-integrations/langchain-hosted-agents"},{"title":"Use Foundry Memory with LangChain and LangGraph","href":"/developer-tools-and-integrations/langchain-memory"},{"title":"Trace LangChain and LangGraph apps with Microsoft Foundry and Azure Monitor","href":"/developer-tools-and-integrations/langchain-traces"}]},{"group":"Foundry MCP Server (preview)","pages":[{"title":"Get started using Foundry MCP Server with Visual Studio Code","href":"/developer-tools-and-integrations/get-started"},{"title":"Explore Foundry MCP Server best practices and security guidance","href":"/developer-tools-and-integrations/security-best-practices"},{"title":"Explore available tools and example prompts for Foundry MCP Server (preview)","href":"/developer-tools-and-integrations/available-tools"}]},{"group":"Fireworks on Foundry","pages":[{"title":"Fireworks models on Microsoft Foundry","sidebarTitle":"Fireworks models on Microsoft Foundry","href":"/developer-tools-and-integrations/enable-fireworks-models"},{"title":"Import custom models into Microsoft Foundry with Fireworks","href":"/developer-tools-and-integrations/import-custom-models"},{"title":"Fireworks on Microsoft Foundry privacy and compliance FAQ","sidebarTitle":"Fireworks on Microsoft Foundry privacy and compliance FAQ","href":"/developer-tools-and-integrations/privacy-compliance-faq"}]}]},{"group":"Models","pages":[{"title":"Microsoft Foundry Models overview","href":"/models/foundry-models-overview"},{"group":"Explore Foundry Models","pages":[{"title":"Foundry Models sold by Azure","href":"/models/models-sold-directly-by-azure"},{"title":"Foundry Models sold by Azure in Azure Government","href":"/models/models-sold-directly-by-azure-gov"},{"title":"Foundry Models from partners and community","href":"/models/models-from-partners"},{"title":"Hugging Face models in Microsoft Foundry","href":"/models/hugging-face-models"},{"title":"Data, privacy, and security for Foundry Models sold by Azure in Microsoft Foundry","href":"/models/data-privacy"},{"group":"Benchmark models","pages":[{"title":"Model benchmarks and leaderboards in Microsoft Foundry","href":"/models/model-benchmarks"},{"title":"Compare models using the model leaderboard","href":"/models/benchmark-model-in-catalog"},{"title":"Run benchmark evaluations in Microsoft Foundry","href":"/models/benchmark-evaluations"},{"title":"GPT-5 vs GPT-4.1 - choosing the right model for your use case","href":"/models/model-choice-guide"}]},{"group":"Model versions and lifecycle","pages":[{"title":"Model versioning in Microsoft Foundry Models","href":"/models/model-versions"},{"title":"Model versioning in Microsoft Foundry Models in Azure Government","href":"/models/model-versions-gov"},{"title":"Model migration: upgrade or switch models in Microsoft Foundry","href":"/models/model-migration"},{"title":"Azure OpenAI in Microsoft Foundry Models working with models","href":"/models/working-with-models"},{"title":"Foundry Models lifecycle and support policy","href":"/models/model-retirements"},{"title":"Foundry Models lifecycle and support policy in Azure Government","href":"/models/model-retirements-gov"},{"title":"Model retirement schedule","href":"/models/model-retirement-schedule"},{"title":"Model retirement schedule in Azure Government","href":"/models/model-retirement-schedule-gov"},{"title":"Retired Microsoft Foundry Models","href":"/models/retired-models"}]},{"group":"Model Router","pages":[{"title":"How to use model router for Microsoft Foundry","href":"/models/model-router"},{"title":"What's new in model router in Microsoft Foundry Models","href":"/models/whats-new-model-router"},{"title":"Monitor model router in Microsoft Foundry","href":"/models/monitor-model-router"},{"title":"Evaluate model router for your workload","href":"/models/evaluate-model-router"},{"title":"Govern model router deployments with Azure Policy","href":"/models/model-router-policy"},{"title":"Use model router with Foundry agents","href":"/models/model-router-agents"},{"title":"Auto and direct model routing with the Responses API","href":"/models/responses-model-routing"},{"title":"How model router works in Microsoft Foundry","href":"/models/model-router-how-it-works"}]}]},{"group":"Quota limits and region availability","pages":[{"title":"Region availability for Foundry Models sold by Azure","href":"/models/models-sold-directly-by-azure-region-availability"},{"title":"Manage Azure OpenAI in Microsoft Foundry Models quota","href":"/models/quota"},{"title":"Automate Azure OpenAI deployments with quota in Microsoft Foundry","href":"/models/automate-quota-deployments"},{"title":"Azure OpenAI in Microsoft Foundry Models Quotas and Limits","href":"/models/quotas-limits"},{"title":"Azure OpenAI in Microsoft Foundry Models Quotas and Limits in Azure Government","href":"/models/quotas-limits-gov"},{"title":"Feature availability across cloud regions","href":"/models/region-support"}]},{"group":"Offers, deployment types, and pricing","pages":[{"title":"Deployment overview for Microsoft Foundry Models","href":"/models/deployments-overview"},{"title":"Instant access to models in Microsoft Foundry (preview)","href":"/models/instant-models"},{"title":"Managed compute in Microsoft Foundry","href":"/models/managed-compute-overview"},{"title":"Understanding deployment types in Microsoft Foundry Models","href":"/models/deployment-types"},{"title":"Understand deployment types in Microsoft Foundry Models in Azure Government","href":"/models/deployment-types-gov"},{"title":"How to use global batch processing with Azure OpenAI in Microsoft Foundry Models","href":"/models/batch"},{"title":"Use Flex processing with Azure OpenAI in Foundry Models (preview)","href":"/models/flex-processing"},{"title":"Enable priority processing for Microsoft Foundry Models","href":"/models/priority-processing"},{"title":"Plan and Manage Costs","href":"/models/manage-costs"},{"group":"Provisioned throughput","pages":[{"title":"Provisioned throughput for Foundry Models","href":"/models/provisioned-throughput"},{"title":"Provisioned throughput for Foundry Models in Azure Government","href":"/models/provisioned-throughput-gov"},{"title":"Quickstart: Create a provisioned throughput deployment","href":"/models/provisioned-quickstart"},{"title":"Determine PTU sizing for a workload","href":"/models/provisioned-throughput-sizing"},{"title":"Provisioned throughput billing and cost management","href":"/models/provisioned-throughput-billing"},{"title":"Operate provisioned throughput deployments in production","href":"/models/provisioned-get-started"},{"title":"Manage traffic with spillover for provisioned deployments","href":"/models/spillover-traffic-management"}]}]},{"group":"Model deployment","pages":[{"title":"Deploy Microsoft Foundry Models in the Foundry portal","href":"/models/deploy-foundry-models"},{"title":"Deploy models using Azure CLI and Bicep","href":"/models/create-model-deployments"},{"title":"Migrate from GitHub Models to Microsoft Foundry Models","href":"/models/quickstart-github-models"},{"title":"Deploy open-source models with managed compute in Microsoft Foundry","href":"/models/deploy-models-managed"},{"title":"How to troubleshoot your deployments and monitors in Microsoft Foundry portal (classic)","href":"/models/troubleshoot-deploy-and-monitor"},{"title":"Troubleshoot common HTTP errors - Azure OpenAI in Microsoft Foundry","href":"/models/troubleshoot-errors"}]},{"group":"Model support","pages":[{"title":"Azure OpenAI SDK language support","href":"/models/supported-languages"},{"title":"Deploy and use FLUX models in Microsoft Foundry","href":"/models/use-foundry-models-flux"},{"title":"Deploy and use Grok models in Microsoft Foundry","href":"/models/use-foundry-models-grok"},{"group":"Microsoft AI (MAI)","pages":[{"title":"Deploy and use MAI image models in Microsoft Foundry","href":"/models/use-foundry-models-mai-image"},{"title":"Deploy and use MAI-Thinking-1 in Microsoft Foundry","href":"/models/use-foundry-models-mai-thinking"},{"title":"What is MAI-Voice?","sidebarTitle":"What is MAI-Voice?","href":"/models/mai-voices"},{"title":"MAI-Transcribe-2 - Speech Service","sidebarTitle":"MAI-Transcribe-2 - Speech Service","href":"/models/mai-transcribe"}]},{"group":"Anthropic","pages":[{"title":"Claude models in Microsoft Foundry","href":"/models/claude-models"},{"title":"Claude Model Quotas and Rate Limits","href":"/models/claude-models-quotas-limits"},{"title":"Compare hosting options for Claude models in Microsoft Foundry","href":"/models/claude-models-hosting-comparison"},{"title":"Deploy and use Claude models in Microsoft Foundry","href":"/models/use-foundry-models-claude"}]},{"group":"Healthcare AI models","pages":[{"title":"Healthcare AI models in Microsoft Foundry","sidebarTitle":"Healthcare AI models in Microsoft Foundry","href":"/models/healthcare-ai-models"},{"title":"Deploy and use MedImageInsight Premium in Foundry","sidebarTitle":"Deploy and use MedImageInsight Premium in Foundry","href":"/models/deploy-medimageinsight-premium"},{"title":"Deploy and use CxrReportGen Premium in Foundry","sidebarTitle":"Deploy and use CxrReportGen Premium in Foundry","href":"/models/deploy-cxrreportgen-premium"}]}]},{"group":"Develop with AI models","pages":[{"title":"Endpoints for Microsoft Foundry Models","href":"/models/endpoints"},{"title":"Codex with Azure OpenAI in Microsoft Foundry Models","href":"/models/codex"},{"title":"Azure OpenAI in Foundry Models Webhooks","href":"/models/webhooks"},{"group":"Chat completions and Responses APIs","pages":[{"title":"Work with chat completion models","href":"/models/chatgpt"},{"title":"How to use predicted outputs with Azure OpenAI in Microsoft Foundry Models","href":"/models/predicted-outputs"},{"title":"Prompt caching with Azure OpenAI in Microsoft Foundry Models","href":"/models/prompt-caching"},{"title":"Azure OpenAI reasoning models - GPT-6 Astra and GPT-5","href":"/models/reasoning"},{"title":"Microsoft Foundry reasoning models","href":"/models/use-chat-reasoning"},{"group":"Responses API","pages":[{"title":"Use the Azure OpenAI Responses API","href":"/models/responses"},{"title":"How to generate text responses with Microsoft Foundry Models","href":"/models/generate-responses"},{"title":"How to use function calling with Microsoft Foundry Models","href":"/models/function-calling"},{"title":"Use multi-agent orchestration with the Azure OpenAI Responses API","href":"/models/responses-multi-agent"},{"title":"How to use structured outputs with Azure OpenAI in Microsoft Foundry Models","href":"/models/structured-outputs"},{"title":"How to use JSON mode with Azure OpenAI in Microsoft Foundry Models","href":"/models/json-mode"},{"title":"Deep research with the Responses API","href":"/models/deep-research"},{"title":"Use tool search with the Azure OpenAI Responses API","href":"/models/tool-search"},{"title":"Web search with the Responses API","href":"/models/web-search"},{"title":"WebSocket Mode for Azure OpenAI Responses API","href":"/models/websockets"},{"title":"Use the shell tool with the Responses API","href":"/models/shells"},{"title":"Use skills with the Responses API","href":"/models/skills"}]}]},{"group":"Embeddings","pages":[{"title":"Azure OpenAI in Microsoft Foundry Models embeddings tutorial","href":"/models/embeddings"}]}]},{"group":"Model capabilities","pages":[{"group":"Image and video","pages":[{"title":"How to Use Image Generation Models from OpenAI","href":"/models/dall-e"},{"title":"Image prompt engineering techniques","href":"/models/gpt-4-v-prompt-engineering"},{"title":"Azure OpenAI prompt transformation concepts","href":"/models/prompt-transformation"},{"title":"Sora 2 video generation overview (preview)","href":"/models/video-generation"},{"title":"How to use vision-enabled chat models","href":"/models/gpt-with-vision"},{"title":"How to use video translation - Speech service","sidebarTitle":"How to use video translation - Speech service","href":"/models/video-translation-get-started"}]},{"group":"Audio and speech","pages":[{"title":"Quickstart - Get started with Azure OpenAI audio generation","description":"Get started with audio generation using Azure OpenAI.","href":"/models/audio-completions-quickstart"},{"title":"Speech to text quickstart","sidebarTitle":"Speech to text quickstart","href":"/models/get-started-speech-to-text"},{"title":"Speech to text with transcription models","description":"Learn how to use Azure OpenAI transcription models for speech to text conversion.","href":"/models/whisper-quickstart"},{"title":"Text to speech quickstart - Speech service","sidebarTitle":"Text to speech quickstart - Speech service","href":"/models/get-started-text-to-speech"},{"title":"How to use batch synthesis for text to speech avatar - Speech service","sidebarTitle":"How to use batch synthesis for text to speech avatar - Speech service","href":"/models/batch-synthesis-avatar"},{"title":"Get started with Voice Live for real-time voice agents","sidebarTitle":"Get started with Voice Live for real-time voice agents","href":"/models/voice-live-quickstart"},{"group":"GPT-Live","pages":[{"title":"Use GPT-Live for real-time voice","sidebarTitle":"Use GPT-Live for real-time voice","href":"/models/gpt-live"},{"title":"Use GPT-Live via WebRTC","sidebarTitle":"Use GPT-Live via WebRTC","href":"/models/gpt-live-webrtc"},{"title":"Delegate work in GPT-Live","sidebarTitle":"Delegate work in GPT-Live","href":"/models/gpt-live-delegation"}]}]},{"group":"Realtime API","pages":[{"title":"GPT Realtime 2.x overview","href":"/models/realtime-2"},{"title":"Use the GPT Realtime API for speech and audio with Azure OpenAI","href":"/models/realtime-audio"},{"title":"Use the GPT Realtime API via WebRTC","href":"/models/realtime-audio-webrtc"},{"title":"Use the GPT Realtime API via WebSockets","href":"/models/realtime-audio-websockets"},{"title":"Use the GPT Realtime API via SIP","href":"/models/realtime-audio-sip"},{"title":"Migration from Preview to GA version of Realtime API","href":"/models/realtime-audio-preview-api-migration-guide"},{"title":"GPT Realtime Translate overview","href":"/models/gpt-realtime-translate"},{"title":"GPT Realtime Transcribe overview","href":"/models/gpt-realtime-whisper"}]}]},{"group":"Fine-tuning","pages":[{"title":"Microsoft Foundry fine-tuning considerations","href":"/models/fine-tuning-considerations"},{"title":"Deploy a fine-tuned model","href":"/models/fine-tuning-deploy"},{"title":"Fine-tune AI models in Microsoft Foundry with the Azure Developer CLI fine-tuning extension","href":"/models/fine-tune-cli"},{"title":"Generate synthetic data with Microsoft Foundry (Preview)","href":"/models/data-generation"},{"title":"Safety evaluation for fine-tuning (preview)","href":"/models/fine-tuning-safety-evaluation"},{"title":"Fine-tuning cost management","href":"/models/fine-tuning-cost-management"},{"group":"Fine-tune models","pages":[{"title":"Customize a model with fine-tuning","href":"/models/fine-tuning"},{"group":"Healthcare models","pages":[{"title":"Customize a premium healthcare AI model with fine-tuning","sidebarTitle":"Customize a premium healthcare AI model with fine-tuning","href":"/models/fine-tune-premium-healthcare-models"},{"title":"Fine-tune MedImageInsight Premium in Microsoft Foundry","sidebarTitle":"Fine-tune MedImageInsight Premium in Microsoft Foundry","href":"/models/fine-tune-medimageinsight-premium"},{"title":"Fine-tune CxrReportGen Premium in Microsoft Foundry","sidebarTitle":"Fine-tune CxrReportGen Premium in Microsoft Foundry","href":"/models/fine-tune-cxrreportgen-premium"}]}]},{"group":"Advanced techniques","pages":[{"title":"Vision fine-tuning","href":"/models/fine-tuning-vision"},{"title":"Direct preference optimization","href":"/models/fine-tuning-direct-preference-optimization"},{"title":"Reinforcement fine-tuning","href":"/models/reinforcement-fine-tuning"},{"title":"Fine-tuning function calls with Azure OpenAI in Microsoft Foundry Models","href":"/models/fine-tuning-functions"}]}]},{"group":"Development best practices","pages":[{"title":"Prompt engineering techniques | Microsoft Foundry Models","href":"/models/prompt-engineering"},{"title":"Tutorial: Get started with a DeepSeek reasoning model in Foundry Models","href":"/models/get-started-deepseek-r1"},{"title":"System message design for Azure OpenAI","href":"/models/advanced-prompt-engineering"},{"title":"Azure OpenAI in Microsoft Foundry Models performance \u0026 latency","href":"/models/latency"},{"title":"Integrate Microsoft Foundry with your applications","href":"/models/integrate-with-other-apps"}]}]},{"group":"Agents","pages":[{"title":"What is Microsoft Foundry Agent Service?","href":"/agents/overview"},{"group":"Concepts","pages":[{"title":"Agent development lifecycle in Microsoft Foundry","href":"/agents/development-lifecycle"},{"title":"Agent identity concepts in Microsoft Foundry","href":"/agents/agent-identity"},{"title":"Routines in Foundry Agent Service","href":"/agents/routines"},{"title":"Build a workflow in Microsoft Foundry (Preview)","href":"/agents/workflow"},{"group":"Agent 365","pages":[{"title":"Microsoft Agent 365 integration with Foundry","href":"/agents/agent-365-integration"},{"title":"Grant Agent 365 observability permissions","href":"/agents/grant-agent-365-permissions"}]}]},{"group":"Prompt agents","pages":[{"group":"Text-based agents","pages":[{"group":"Quickstarts","pages":[{"title":"Quickstart: Build agents using the Responses API","href":"/agents/responses-api"}]},{"group":"Build","pages":[{"title":"Use connected Foundry models in Foundry Agent Service","href":"/agents/connected-models"},{"title":"Customize Agent Behavior at Runtime with Structured Inputs","href":"/agents/structured-inputs"},{"title":"Agent applications in Microsoft Foundry","href":"/agents/agent-applications"},{"title":"Configure and share your Microsoft Foundry agent","href":"/agents/configure-agent"},{"title":"Tool best practices for Microsoft Foundry Agent Service","href":"/agents/tool-best-practice"},{"title":"Agent optimizer in Foundry Agent Service overview (preview)","href":"/agents/agent-optimizer-overview"},{"title":"Agent optimizer cost and token usage overview","href":"/agents/agent-optimizer-costs"},{"title":"Quickstart: Optimize a prompt agent (preview)","sidebarTitle":"Quickstart: Optimize a prompt agent (preview)","href":"/agents/quickstart-optimize-prompt-agent"}]},{"group":"Deploy and share","pages":[{"title":"Enable incoming A2A on a Foundry agent","href":"/agents/enable-agent-to-agent-endpoint"},{"title":null,"href":"/agents/use-routines"}]},{"group":"Migrate","pages":[{"title":"Migrate to the new Foundry Agent Service","href":"/agents/migrate"},{"title":"Migrate from Agent Applications to the new Microsoft Foundry agent model","href":"/agents/migrate-agent-applications"},{"title":"Disable creation of classic agents and assistants","href":"/agents/disable-classic-agents"}]}]},{"group":"Voice-first agents","pages":[{"title":"Publish and share a voice-based agent","href":"/agents/voice-agent-channels-publish"},{"title":"Migrate from Voice Live with Foundry Agent Service to Microsoft Foundry voice agents","href":"/agents/migrate-from-voice-live"},{"group":"Build","pages":[{"title":"Configure a voice agent","href":"/agents/configure-voice-agent"},{"title":"Use a hosted agent as the conversation engine in a voice-based agent","href":"/agents/voice-first-with-hosted-agent"},{"title":"Use a subagent in a Voice-based agent","href":"/agents/use-subagent-voice-first-agent"},{"title":"Integrate telephony channels with a voice agent","href":"/agents/voice-agent-telephony-channels"},{"title":"Best practices for voice-based agents","href":"/agents/voice-agent-best-practice"},{"title":"Optimize voice agent instructions","href":"/agents/optimize-voice-agent-instructions"},{"title":"Voice agent tracing, monitoring, and evaluation","href":"/agents/voice-agent-observability"},{"title":"Pricing for voice-based agents","href":"/agents/voice-agent-pricing"}]}]}]},{"group":"Hosted agents","pages":[{"group":"Concepts","pages":[{"title":"Hosted agents in Foundry Agent Service","href":"/agents/hosted-agents"},{"title":"Build with runtime components in Foundry Agent Service","href":"/agents/runtime-components"},{"title":"Hosted agent runtime contract","href":"/agents/hosted-agent-contract"},{"title":"Resilience for long-running Microsoft Foundry hosted agents (preview)","href":"/agents/long-running-agent-resilience"},{"title":"Durable state store for Microsoft Foundry hosted agents (preview)","href":"/agents/agent-state-store"},{"title":"Long-running agent API reference (preview)","href":"/agents/long-running-agent-reference"}]},{"group":"Quickstarts","pages":[{"title":"Quickstart: Deploy your first hosted agent","href":"/agents/quickstart-hosted-agent"},{"title":"Quickstart: Build a toolbox and use it with a hosted agent","href":"/agents/quickstart-toolbox-agent"},{"title":"Quickstart: Add a Foundry IQ knowledge base to a hosted agent with a toolbox","href":"/agents/quickstart-foundry-iq-hosted-agent"},{"title":"Quickstart - Deploy a hosted agent with browser automation","href":"/agents/browser-automation-hosted-agent-quickstart"},{"title":"Quickstart: Give a hosted agent persistent memory","href":"/agents/quickstart-memory-hosted-agent"},{"title":"Quickstart: Evaluate your hosted agent","href":"/agents/quickstart-evaluate-hosted-agent"},{"title":"Quickstart: Optimize a hosted agent (preview)","href":"/agents/quickstart-optimize-hosted-agent"},{"title":"Quickstart: Trace your hosted agent","href":"/agents/quickstart-tracing-hosted-agent"},{"title":"Quickstart: Deploy your own code as a hosted agent","href":"/agents/quickstart-deploy-own-code"},{"title":"Set up CI/CD for a hosted agent","href":"/agents/set-up-cicd-hosted-agent"}]},{"group":"Develop","pages":[{"title":"Initialize a hosted agent project with the Azure Developer CLI","href":"/agents/init-agent-project"},{"title":"Author azure.yaml for hosted agents","href":"/agents/author-azure-yaml"},{"title":"Use a toolbox with a hosted agent in Microsoft Foundry","href":"/agents/use-toolbox-hosted-agent"},{"title":"Configure environment variables for a hosted agent","href":"/agents/configure-hosted-agent-env-variables"},{"title":"Update the model for a hosted agent","href":"/agents/update-hosted-agent-model"},{"title":"Add a protocol adapter to your hosted agent","href":"/agents/add-protocol-adapter"},{"title":"Use on-behalf-of flow with hosted agents in Microsoft Foundry","href":"/agents/use-on-behalf-of-flow"},{"title":"Host Microsoft Agent Framework agents as Foundry hosted agents","href":"/agents/framework-hosted-agents"}]},{"group":"Run, test, and debug","pages":[{"title":"Run a hosted agent locally with the Azure Developer CLI","href":"/agents/run-hosted-agent-locally"},{"title":"Invoke a hosted agent with the Azure Developer CLI","href":"/agents/invoke-hosted-agent"},{"title":"Inspect a local agent with the Agent Inspector","href":"/agents/agent-inspector"},{"title":"Test a hosted agent","href":"/agents/test-hosted-agent"},{"title":"Debug a hosted agent","href":"/agents/debug-hosted-agent"},{"title":"Configure and share your Microsoft Foundry agent","href":"/agents/configure-agent"},{"title":"Diagnose a project with agent doctor","href":"/agents/agent-doctor"},{"title":"Monitor hosted agent logs with the Azure Developer CLI","href":"/agents/monitor-hosted-agent-logs"},{"title":"Export hosted agent telemetry by using OpenTelemetry","href":"/agents/configure-hosted-agent-telemetry"},{"title":"Monitor agents with the Agent Monitoring Dashboard","href":"/agents/how-to-monitor-agents-dashboard"},{"title":"Isolate hosted agent sessions per user","href":"/agents/isolate-sessions-per-user"},{"title":"Multiplex multiple users in one hosted agent session","href":"/agents/multiplex-session-users"},{"title":"Pass isolation keys to a hosted agent","href":"/agents/pass-isolation-keys"},{"title":"Make your hosted agent optimizer-ready in Foundry Agent Service (preview)","href":"/agents/make-agent-optimizer-ready"},{"title":"Create an evaluation dataset and evaluators for the agent optimizer (preview)","href":"/agents/create-optimizer-dataset"},{"title":"Optimize agent instructions, skills, tools, and models in Foundry Agent Service (preview)","href":"/agents/optimize-agent-targets"},{"title":"Optimize agent prompts with Prompt Optimizer (preview)","href":"/agents/prompt-optimizer"}]},{"group":"Build long-running agents (preview)","pages":[{"title":"Deploy a crash-resilient long-running agent (preview)","href":"/agents/deploy-resilient-agent"},{"title":"Deploy a steerable agent (preview)","href":"/agents/deploy-steerable-agent"},{"title":"Recover long-running work after a crash (preview)","href":"/agents/recover-long-running-work"},{"title":"Steer an in-flight agent turn (preview)","href":"/agents/steer-hosted-agent"},{"title":"Cancel a hosted agent turn (preview)","href":"/agents/cancel-hosted-agent-turn"},{"title":"Add a human-in-the-loop approval step (preview)","href":"/agents/add-human-in-the-loop"},{"title":"Stream long-running agent output with reconnect (preview)","href":"/agents/stream-with-reconnect"},{"title":"Manage state for long-running agents (preview)","href":"/agents/manage-task-state"}]},{"group":"Deploy and operate","pages":[{"title":"Deploy a hosted agent","href":"/agents/deploy-hosted-agent"},{"title":"Build a voice agent with hosted agents","href":"/agents/build-voice-agent"},{"title":"Use a hosted agent as the conversation engine in a voice-based agent","href":"/agents/voice-first-with-hosted-agent"},{"title":"Add guardrails to a hosted agent","href":"/agents/add-hosted-agent-guardrails"},{"title":"Manage hosted agents","href":"/agents/manage-hosted-agent"},{"title":"Manage hosted agent sessions","href":"/agents/manage-hosted-sessions"}]},{"group":"Migrate","pages":[{"title":"Migrate from Agent Applications to the new Microsoft Foundry agent model","href":"/agents/migrate-agent-applications"},{"title":"Disable creation of classic agents and assistants","href":"/agents/disable-classic-agents"}]},{"group":"Ship to production","pages":[{"title":"Set up CI/CD for hosted agents with the Azure Developer CLI","href":"/agents/set-up-ci-cd-cli"},{"title":"Promote hosted agents to production with the Azure Developer CLI","href":"/agents/deploy-hosted-agent-production"},{"title":"Deploy a hosted agent with a private Azure Container Registry","href":"/agents/deploy-hosted-agent-private-azure-container-registry"},{"title":"Bring your own registry for hosted agents","href":"/agents/private-registry-connections"},{"title":"Update a hosted agent endpoint and agent card","href":"/agents/update-agent-endpoint-cli"},{"title":"Migrate hosted agents to the latest version","href":"/agents/migrate-hosted-agent-preview"}]},{"group":"Reference","pages":[{"title":"Hosted agent permissions reference","href":"/agents/hosted-agent-permissions"},{"title":"azure.yaml reference for hosted agents","href":"/agents/azure-yaml-reference"},{"title":"agent.yaml schema reference","href":"/agents/agent-yaml-reference"},{"title":"Hosted agent infrastructure with the Azure Developer CLI","href":"/agents/cli-infrastructure"}]}]},{"group":"Autopilots","pages":[{"title":"What is an autopilot in Microsoft Foundry?","href":"/agents/autopilot-overview"},{"title":"Autopilot lifecycle in Microsoft Foundry","href":"/agents/autopilot-lifecycle"},{"title":"Quickstart: Build your first autopilot","href":"/agents/agent-365"}]},{"group":"Publish and share","pages":[{"title":"Publish agents to Microsoft Copilot and Microsoft Teams","href":"/agents/publish-copilot"},{"title":"Publish agents to Microsoft 365 and Teams by using the REST API","href":"/agents/publish-copilot-virtual-network"},{"group":"Troubleshooting","pages":[{"title":"Troubleshoot publishing agents to Microsoft Copilot and Microsoft Teams","href":"/agents/troubleshoot-publish-copilot"},{"title":"Troubleshoot authorization errors for agents published to Microsoft Copilot and Teams","href":"/agents/troubleshoot-publish-copilot-authorization"}]}]},{"group":"Reference","pages":[{"title":"Quotas and limits for Microsoft Foundry Agent Service","href":"/agents/limits-quotas-regions"},{"title":"Foundry Agent Service feature availability in Azure Government","sidebarTitle":"Foundry Agent Service feature availability in Azure Government","href":"/agents/azure-government"},{"title":"Capability hosts for Foundry Agent Service","href":"/agents/capability-hosts"},{"title":"Foundry Agent Service frequently asked questions","href":"/agents/faq"}]}]},{"group":"Toolboxes","pages":[{"title":"Create and manage a toolbox in Microsoft Foundry","href":"/toolboxes/toolbox"},{"title":"Enable tool search in a toolbox","href":"/toolboxes/tool-search"},{"group":"Add tools and skills","pages":[{"title":"Use skills with Microsoft Foundry agents (preview)","href":"/toolboxes/skills"},{"title":"Create a private skill catalog in Foundry Agent Service","href":"/toolboxes/private-skill-catalog"},{"title":"Connect OpenAPI tools to Microsoft Foundry agents","href":"/toolboxes/openapi"},{"title":"File search tool for Microsoft Foundry agents","href":"/toolboxes/file-search"},{"title":"Use Code Interpreter with Microsoft Foundry agents","href":"/toolboxes/code-interpreter"},{"title":"Connect an Azure AI Search index to Foundry agents","href":"/toolboxes/ai-search"},{"group":"MCP","pages":[{"title":"Connect agents to MCP server endpoints","href":"/toolboxes/model-context-protocol"},{"title":"Add managed MCP servers powered by connector namespaces (preview)","href":"/toolboxes/connectors"},{"title":"Set up MCP server authentication","href":"/toolboxes/mcp-authentication"},{"title":"Build and register a Model Context Protocol (MCP) server","href":"/toolboxes/build-your-own-mcp-server"},{"title":"Create a private tool catalog in Foundry Agent Service","href":"/toolboxes/private-tool-catalog"}]},{"group":"A2A","pages":[{"title":"Connect to an A2A agent endpoint from Foundry Agent Service","href":"/toolboxes/agent-to-agent"},{"title":"Agent2Agent (A2A) authentication","href":"/toolboxes/agent-to-agent-authentication"}]},{"group":"Web and Bing tools","pages":[{"title":"Overview of web grounding capabilities in Foundry","href":"/toolboxes/web-overview"},{"title":"Use web search tool in Foundry Agent Service","href":"/toolboxes/web-search"},{"title":"Use Grounding with Bing Search tools with the agents API","href":"/toolboxes/bing-tools"}]},{"group":"Microsoft IQ","pages":[{"title":"Connect agents to Microsoft Fabric with Fabric IQ (preview)","href":"/toolboxes/fabric-iq"},{"title":"Connect agents to Microsoft 365 with Work IQ (preview)","href":"/toolboxes/work-iq"},{"group":"Foundry IQ","pages":[{"title":"What is Foundry IQ?","href":"/toolboxes/what-is-foundry-iq"},{"title":"Foundry IQ frequently asked questions","href":"/toolboxes/foundry-iq-faq"},{"title":"Connect Agents to Foundry IQ Knowledge Bases","href":"/toolboxes/foundry-iq-connect"},{"group":"Tutorial: Deploy private agentic retrieval","pages":[{"title":"Tutorial: Deploy Private Agentic Retrieval","sidebarTitle":"Tutorial: Deploy Private Agentic Retrieval","href":"/toolboxes/foundry-iq-tutorial-private-overview"},{"title":"Set Up Private Inbound Connectivity","sidebarTitle":"Set Up Private Inbound Connectivity","href":"/toolboxes/foundry-iq-tutorial-private-inbound"},{"title":"Set Up Private Outbound Connectivity","sidebarTitle":"Set Up Private Outbound Connectivity","href":"/toolboxes/foundry-iq-tutorial-private-outbound"},{"title":"Validate End-to-End Private Agentic Retrieval","sidebarTitle":"Validate End-to-End Private Agentic Retrieval","href":"/toolboxes/foundry-iq-tutorial-private-retrieval"}]}]}]},{"group":"File search","pages":[{"title":"Retrieval augmented generation (RAG) and indexes in Microsoft Foundry","href":"/toolboxes/retrieval-augmented-generation"},{"title":"Vector stores for file search in Foundry Agent Service","href":"/toolboxes/vector-stores"}]},{"group":"Code interpreter","pages":[{"title":"Configure a custom code interpreter for agents","href":"/toolboxes/custom-code-interpreter"}]},{"group":"Other tools","pages":[{"title":"Use function calling with Microsoft Foundry agents","href":"/toolboxes/function-calling"},{"title":"Reminder tool for self-scheduling hosted agents","href":"/toolboxes/reminder-tool"},{"title":"Use the computer use tool for agents","href":"/toolboxes/computer-use"},{"title":"Use the image generation tool (preview) in Foundry Agent Service","href":"/toolboxes/image-generation"},{"title":"Use the Microsoft Fabric data agent with Foundry agents","href":"/toolboxes/fabric"},{"title":"Use SharePoint with the Foundry Agent Service API","href":"/toolboxes/sharepoint"},{"title":"Integrate Azure Functions with Foundry Agents","sidebarTitle":"Integrate Azure Functions with Foundry Agents","href":"/toolboxes/azure-functions"},{"group":"Browser automation (preview)","pages":[{"title":"Automate browser tasks with Foundry agents","href":"/toolboxes/browser-automation"}]},{"group":"Foundry Tools","pages":[{"title":"Connect Azure Speech in Foundry Tools to an agent","href":"/toolboxes/azure-ai-speech"},{"group":"Azure Language","pages":[{"title":"Azure Language in Foundry Tools - tools and agents","sidebarTitle":"Azure Language in Foundry Tools - tools and agents","href":"/toolboxes/foundry-tools-agents"},{"title":"Quickstart: Multi-turn conversational language understanding (CLU) models with entity slot filling","sidebarTitle":"Quickstart: Multi-turn conversational language understanding (CLU) models with entity slot filling","href":"/toolboxes/quickstart-multi-turn-conversations"},{"title":"Quickstart: Detect the language of text","sidebarTitle":"Quickstart: Detect the language of text","href":"/toolboxes/quickstart"}]},{"group":"Azure Translator","pages":[{"title":"What is Azure Translator document translation?","sidebarTitle":"What is Azure Translator document translation?","href":"/toolboxes/overview"}]}]},{"group":"Voice","pages":[{"title":"Quickstart: Voice Agent with Foundry Agent Service (new)","sidebarTitle":"Quickstart: Voice Agent with Foundry Agent Service (new)","href":"/toolboxes/voice-live-agents-quickstart"},{"title":"How to build a voice agent","sidebarTitle":"How to build a voice agent","href":"/toolboxes/how-to-voice-agent-integration"}]},{"group":"Memory (preview)","pages":[{"title":"What is Memory?","href":"/toolboxes/what-is-memory"},{"title":"Create and use memory in Foundry Agent Service","href":"/toolboxes/memory-usage"}]}]}]},{"group":"Manage toolbox","pages":[{"title":"Create and manage a toolbox in Microsoft Foundry","href":"/toolboxes/toolbox"},{"title":"Govern MCP Tools by Using an AI Gateway","href":"/toolboxes/governance"},{"title":"Toolbox authentication in Microsoft Foundry","href":"/toolboxes/tool-authentication"},{"title":"Network isolation for a toolbox in Microsoft Foundry","href":"/toolboxes/toolbox-network-isolation"}]}]},{"group":"Observability","pages":[{"title":"Observability in Generative AI","href":"/observability/observability"},{"title":"Troubleshoot evaluation and observability issues - Microsoft Foundry","href":"/observability/troubleshooting"},{"group":"Monitoring","pages":[{"title":"Microsoft Foundry Notification Center overview","href":"/observability/concept-notification-center"},{"title":"Monitor agents with the Agent Monitoring Dashboard","href":"/observability/how-to-monitor-agents-dashboard"},{"title":"Use Insights in Foundry","href":"/observability/agent-insights"},{"title":"Log end user feedback","href":"/observability/log-end-user-feedback"},{"title":"Monitor Model Deployments in Microsoft Foundry Models","href":"/observability/monitor-models"}]},{"group":"Tracing","pages":[{"title":"Agent tracing overview","href":"/observability/trace-agent-concept"},{"title":"Quickstart: Trace your hosted agent","href":"/observability/quickstart-tracing-hosted-agent"},{"title":"Set Up Tracing for AI Agents in Microsoft Foundry","href":"/observability/trace-agent-setup"},{"title":"Configure Microsoft Entra authentication for Foundry Agent trace ingestion (preview)","sidebarTitle":"Configure Microsoft Entra authentication for Foundry Agent trace ingestion (preview)","href":"/observability/trace-ingestion-entra-authentication"},{"title":"Review agent interactions with Trace Replay","href":"/observability/trace-agent-replay"},{"title":"Add client-side tracing to Foundry agents","href":"/observability/trace-agent-client-side"},{"title":"Configure tracing for AI agent frameworks","sidebarTitle":"Configure tracing for AI agent frameworks","href":"/observability/trace-agent-framework"},{"title":"Register external agents for observability and evaluation","href":"/observability/register-external-agent"},{"title":"Convert agent traces into evaluation datasets (preview)","href":"/observability/traces-to-dataset"},{"title":"Annotate traces with human feedback","href":"/observability/trace-annotations"},{"title":"Restrict access to sensitive content in Microsoft Foundry traces","href":"/observability/traces-sensitive-content"},{"title":"Microsoft Foundry Tracing and Data Handling","href":"/observability/trace-data"}]}]},{"group":"Evaluation","pages":[{"title":"Set up permissions for Microsoft Foundry evaluation workflows","href":"/evaluation/evaluation-permissions"},{"title":"Rate limits, region support, and enterprise features for evaluation","href":"/evaluation/evaluation-regions-limits-virtual-network"},{"title":"Configure virtual network support for evaluation in Microsoft Foundry","href":"/evaluation/evaluation-virtual-network"},{"title":"Microsoft Foundry risk and safety evaluations Transparency Note","href":"/evaluation/safety-evaluations-transparency-note"},{"group":"Supported evaluators","pages":[{"title":"Built-in Evaluators Reference","href":"/evaluation/built-in-evaluators"},{"title":"General Purpose Evaluators for Generative AI","href":"/evaluation/general-purpose-evaluators"},{"title":"Textual Similarity Evaluators for Generative AI","href":"/evaluation/textual-similarity-evaluators"},{"title":"Retrieval-Augmented Generation (RAG) Evaluators for Generative AI","href":"/evaluation/rag-evaluators"},{"title":"Risk and Safety Evaluators for Generative AI","href":"/evaluation/risk-safety-evaluators"},{"title":"Agent Evaluators for Generative AI","href":"/evaluation/agent-evaluators"},{"title":"Azure OpenAI Graders for generative AI","href":"/evaluation/azure-openai-graders"},{"title":"Rubric evaluators","href":"/evaluation/rubric-evaluators"},{"title":"Custom Evaluators","href":"/evaluation/custom-evaluators"}]},{"group":"Evaluation datasets","pages":[{"title":"Evaluation datasets in Microsoft Foundry","href":"/evaluation/evaluation-datasets"},{"title":"Evaluation dataset schema in Microsoft Foundry","href":"/evaluation/evaluation-dataset-schema"},{"title":"Generate a synthetic evaluation dataset (preview)","href":"/evaluation/evaluation-dataset-synthetic"}]},{"group":"Run evaluations","pages":[{"title":"Evaluate your AI agents","href":"/evaluation/evaluate-agent"},{"title":"Run evaluations from the Microsoft Foundry portal","href":"/evaluation/evaluate-generative-ai-app"},{"title":"Run agent evaluations with the azd CLI (preview)","href":"/evaluation/azure-developer-cli-evaluation"},{"group":"Run evaluations with the SDK","pages":[{"title":"Introduction to cloud evaluation with Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation"},{"title":"Get cloud evaluation results with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-results"},{"title":"Use admin-connected models in cloud evaluations","href":"/evaluation/evaluate-admin-connected-models"},{"group":"Evaluate individual turns","pages":[{"title":"Evaluate datasets with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-datasets"},{"title":"Evaluate models and agents with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-targets"},{"title":"Evaluate deployed interactions with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-deployed-interactions"},{"title":"Generate synthetic data with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-synthetic-data"}]},{"group":"Evaluate complete conversations","pages":[{"title":"Evaluate conversation datasets with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-conversations"},{"title":"Evaluate deployed model and agent conversations with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-deployed-conversations"},{"title":"Simulate conversations with the Microsoft Foundry SDK","href":"/evaluation/cloud-evaluation-simulate-conversations"}]}]},{"group":"Specialized evaluation workflows","pages":[{"title":"Human Evaluation for Microsoft Foundry Agents","href":"/evaluation/human-evaluation"}]},{"group":"Review and analyze results","pages":[{"title":"See Evaluation Results in Microsoft Foundry portal","href":"/evaluation/evaluate-results"},{"title":"Evaluation Cluster Analysis","href":"/evaluation/cluster-analysis"}]}]},{"group":"AI red teaming","pages":[{"title":"AI Red Teaming Agent","href":"/evaluation/ai-red-teaming-agent"},{"title":"Run AI Red Teaming Agent in the cloud (Microsoft Foundry SDK)","href":"/evaluation/run-ai-red-teaming-cloud"},{"title":"Run AI Red Teaming Agent Locally (Azure AI Evaluation SDK)","href":"/evaluation/run-scans-ai-red-teaming-agent"}]},{"group":"Evaluations in CI/CD pipelines","pages":[{"title":"How to run an evaluation in GitHub Action","href":"/evaluation/evaluation-github-action"},{"title":"How to run an evaluation in Azure DevOps","href":"/evaluation/evaluation-azure-devops"}]}]}]}]},"basePath":"","title":"Speech to text quickstart - Microsoft Foundry Docs","deploymentId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","buildId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","dynamics":[],"chunks":[]}