Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

SpeechRecognitionEngine.SetInputToDefaultAudioDevice 호출 시 System.InvalidOperationException 예외 발생

(업데이트: 2023-03-30) 이 글에 대한 질문은 더 이상 받지 않습니다. (하시다 보면, 제가 왜 이 기술에 대해 흥미를 못 느끼는 지 아시게 될 것입니다. ^^ SpeechRecognitionEngine에 특별한 업데이트가 없는 한 다루지 않을 것입니다.)




C#으로 만드는 음성인식/TTS 프로그램
; https://www.sysnet.pe.kr/2/0/1228

위의 예제 코드에서, SetInputToDefaultAudioDevice 메서드 호출 시 예외가 발생할 수 있습니다.

using (SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine("SR_MS_ko-KR_TELE_11.0"))
{
    Grammar grammar = new Grammar("computer.xml");

    recognizer.LoadGrammar(grammar);

    recognizer.SetInputToDefaultAudioDevice(); <== System.InvalidOperationException 예외 발생
    recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

    recognizer.RecognizeAsync(RecognizeMode.Multiple);

    while (true)
    {
        Console.ReadLine();
    }
}

System.InvalidOperationException was unhandled
  Message=Cannot find the requested data item, such as a data key or value.
  Source=System.Speech
  StackTrace:
       at System.Speech.Recognition.RecognizerBase.SetInputToDefaultAudioDevice()
       at ConsoleApplication1.Program.Main(String[] args) in D:\...\ConsoleApplication1\Program.cs:line 37
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

원인은, 가용한 Audio Recording Device가 없어서 그럴 수 있습니다. 예를 들어, 위의 예외가 발생했을 때 제 컴퓨터의 제어판에는 아래와 같이 모든 Recording Device가 비활성 상태였습니다.

speech_audio_error_1.png

이 중에서 하나라도 선택해서 다음과 같이 "Enable" 시켜주면,

speech_audio_error_2.png

이제부터는 SetInputToDefaultAudioDevice 메서드 호출 시에 예외가 발생하지 않습니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 3/30/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... [151]  152  153  154  155  156  157  158  159  160  161  162  163  164  165  ...
NoWriterDateCnt.TitleFile(s)
1370정성태10/31/201225842VS.NET IDE: 75. Visual Studio - "Active Solution Platform" 변경을 툴바에서 하는 방법
1369정성태10/31/201238914개발 환경 구성: 174. 윈도우에서 Mono 개발 환경 구성 [4]
1368정성태10/31/201231140개발 환경 구성: 173. Windows Phone SDK 8.0 설치
1367정성태10/30/201238173개발 환경 구성: 172. IIS 7.5부터 지원되는 웹 사이트 자동 시작 모드 [1]
1366정성태10/24/201229705개발 환경 구성: 171. GTK+를 윈도우 환경에 수작업 설치
1365정성태10/24/201228620개발 환경 구성: 170. 우분투 데스크톱 Active Directory 가입하기 [2]
1364정성태10/19/201225414Windows: 66. Hyper-V 2012에서 별도의 네트워크 카드를 이용한 Live Migration
1363정성태10/16/201232997개발 환경 구성: 169. Objective-C의 대안 - Xamarin의 Mono를 이용한 C# iOS 개발 환경 [2]
1362정성태10/16/201233056개발 환경 구성: 168. 우분투 서버 Active Directory 가입하기
1361정성태10/12/201226366.NET Framework: 341. .NET COM+ 를 Managed/Native 클라이언트에서 각각 호출했을 때의 콜 스택 비교 [4]파일 다운로드1
1360정성태10/9/201231138.NET Framework: 340. Windows Server 2012 - .NET Framework 1.x 미지원
1359정성태10/9/201267172Windows: 65. 윈도우 8 - Internet Explorer 10을 32비트 또는 64비트로 통합 [5]
1358정성태9/27/201230417.NET Framework: 339. .NET Profiler 주의 사항 - 하나의 exe 프로세스 내에 다중 .NET 런타임 사용
1357정성태9/27/201227011Windows: 64. Hyper-V - Windows XP의 Live Migration 오류
1356정성태9/26/201233479Windows: 63. 윈도우 서버 2012 - Hyper-V의 새로운 기능 Live Migration [6]
1355정성태9/21/201231618Team Foundation Server: 49. TFS 2012 Express의 필수 보완 작업: 데이터베이스 백업 [1]
1354정성태9/19/201228605.NET Framework: 338. .NET CLR GC 시간 측정하는 방법파일 다운로드1
1353정성태9/17/201229422.NET Framework: 337. Python의 생성기와 코루틴을 C#으로 표현하면. [2]파일 다운로드1
1352정성태9/13/201227348.NET Framework: 336. .NET Profiler가 COM 개체일까?
1351정성태9/13/201232125디버깅 기술: 49. windbg - .NET Framework 스레드 개체의 COM Apartment 유형 확인하는 방법
1350정성태9/12/201232724개발 환경 구성: 167. (실은) 무료가 아니었던 AWS EC2 서비스 [4]
1349정성태9/11/201264616VS.NET IDE: 74. Visual Studio의 '새 파일'을 UTF-8 인코딩으로 지정하는 방법 [4]
1348정성태9/11/201232011오류 유형: 164. Active Directory - Functional Level 승격이 안 되는 문제
1347정성태9/10/201234899Windows: 62. 윈도우 서버 2012 - Hyper-V 서버 마이그레이션 [1]
1346정성태9/10/201234962Windows: 61. 윈도우 서버 2012 - Active Directory 서버 마이그레이션
1345정성태9/10/201239777스크립트: 12. 파이썬 - Win32 DLL 연동 [2]
... [151]  152  153  154  155  156  157  158  159  160  161  162  163  164  165  ...