Microsoft MVP성태의 닷넷 이야기
오류 유형: 175. SpeechRecognitionEngine 사용 시 오류 유형 2가지 [링크 복사], [링크+제목 복사],
조회: 23046
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

SpeechRecognitionEngine 사용 시 오류 유형 2가지

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




생각했던 것보다, 음성인식에 대한 관심이 많은 것 같습니다. 예전에 썼던 다음의 글이 조회수가 5,000에 육박하고 있으니까요. ^^

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

이번 글은, 아래의 질문에 포함된 예제를 실행해 보면서 겪은 오류 내용을 정리한 것입니다.

음성인식 TTS 관련해서 질문드립니다
; https://www.sysnet.pe.kr/3/0/1142

제가 "C# 으로 만드는 음성인식/TTS 프로그램" 글을 쓴 이후로 노트북이 바뀌어서 전혀 환경 구성이 안되어 있었는데요. 그래도 일단 "음성인식 TTS 관련해서 질문드립니다" 글에 첨부된 소스 코드를 무작정 빌드해서 실행해 보았습니다.

그랬더니, 다음의 코드를 실행할 때 오류가 발생하는 군요. ^^

SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine("SR_MS_ko-KR_TELE_11.0");

예외 메시지는 다음과 같습니다.

Retrieving the COM class factory for component with CLSID {49428A60-C997-4D0E-9808-9E326C178D58} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).


이는 제 컴퓨터에 "Speech Platform"이 설치되어 있지 않아서 그런 것입니다. 따라서, 아래의 사이트에서 런타임을 다운로드 받고,

Microsoft Speech Platform - Runtime 11.0
; http://go.microsoft.com/fwlink/?LinkID=223568

Microsoft Speech Platform - Runtime Languages (Version 11)
- 한글 음성인식: MSSpeech_SR_ko-KR_TELE.msi
; http://www.microsoft.com/download/en/details.aspx?id=27224

다시 시도해 보니, 잘 됩니다.

그 외에 이 오류가 발생할 수 있는 또 한 가지 상황이 있습니다. COM 개체의 특성상 레지스트리 등록 시에 x86/x64를 가리게 되는데요. 이 때문에 64비트 운영체제에 "x64_SpeechPlatformRuntime\SpeechPlatformRuntime.msi"을 설치했다면 당연히 .NET 응용 프로그램도 x64로 동작해야 합니다. 만약 x86으로 빌드했다면 COM 개체의 레지스트리 경로가 달라지기 때문에 "Class not registered"가 떨어지는 것이 맞는 결과입니다.




다음의 상황에서 LoadGrammar 메서드 실행 시에 오류가 발생할 수 있습니다.

SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine("SR_MS_ko-KR_TELE_11.0");

Choices colors = new Choices();
colors.Add(new string[] { "빨강", "파랑", "초록" });
GrammarBuilder gb = colors.ToGrammarBuilder();

Grammar g = new Grammar(gb);
recognizer.LoadGrammar(g); // 오류 발생

예외 메시지는 다음과 같습니다.

System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=The language for the grammar does not match the language of the speech recognizer.
  Source=Microsoft.Speech
  StackTrace:
       at Microsoft.Speech.Recognition.RecognizerBase.ThrowIfSapiErrorCode(SAPIErrorCodes errorCode)
       at Microsoft.Speech.Recognition.MemoryGrammarContent.Load(SapiGrammar sapiGrammar, Boolean enabled, Single weight, Int32 priority)
       at Microsoft.Speech.Recognition.GrammarContent.Load(SapiGrammar sapiGrammar)
       at Microsoft.Speech.Recognition.Grammar.Load(SapiGrammar sapiGrammar, IRecognizerInternal recognizer)
...[생략]...
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

오류 메시지에 따르면 언어가 달라서 그런 것입니다. 이런 경우에는 GrammarBuilder 인스턴스에 언어를 다음과 같이 설정해 주면 해결됩니다.

SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine("SR_MS_ko-KR_TELE_11.0");

Choices colors = new Choices();
colors.Add(new string[] { "빨강", "파랑", "초록" });

GrammarBuilder gb = new GrammarBuilder();
gb.Culture = new System.Globalization.CultureInfo("ko-KR");
gb.Append(colors);

Grammar g = new Grammar(gb);

recognizer.LoadGrammar(g);




"음성인식 TTS 관련해서 질문드립니다" 글에 첨부된 소스 코드에서 초기화를 Form1_Load에서 하고 있는데요. x64 + 윈폼 + Visual Studio 디버그 상태에서는 Form1_Load에서 오류가 발생하는 경우 문제를 찾기가 좀 힘듭니다.

왜냐하면, 그와 같은 조합의 상황에서 예외가 발생하면 Visual Studio는 예외를 먹어버리고 프로그램은 그냥 비정상 종료되어 버립니다. 그나마 Visual Studio의 디버그 창에 다음과 같은 메시지가 남아 있는 정도인데요.

The program '[19588] WindowsFormsApplication3.exe: Managed (v4.0.30319)' has exited with code -1073741819 (0xc0000005) 'Access violation'.

이것은, Windows Forms 응용 프로그램의 고질적인 문제로 x64 응용 프로그램에서만 발생하는 문제입니다. 예전에 한번 이와 관련해서 쓴 적이 있지요. ^^

Windows Form의 Load 이벤트에서 발생하는 예외가 Visual Studio에서 잡히지 않는 문제
; https://www.sysnet.pe.kr/2/0/1107

이런 것이 있다는 것을 참고하시고 디버깅하시면 도움이 될 것입니다.




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

[연관 글]






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

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

비밀번호

댓글 작성자
 




... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12434정성태11/30/202010850Windows: 180. C# - dynamicport 값의 범위를 알아내는 방법
12433정성태11/29/20209920Windows: 179. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (3) - SO_PORT_SCALABILITY파일 다운로드1
12432정성태11/29/202011282Windows: 178. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (2) - SO_REUSEADDR [1]파일 다운로드1
12431정성태11/27/20209204.NET Framework: 976. UnmanagedCallersOnly + C# 9.0 함수 포인터 사용 시 x86 빌드에서 오동작하는 문제파일 다운로드1
12430정성태11/27/20209922오류 유형: 686. Ubuntu - E: The repository 'cdrom://...' does not have a Release file.
12429정성태11/25/202010026디버깅 기술: 175. windbg - 특정 Win32 API에서 BP가 안 걸리는 경우
12428정성태11/25/20208969VS.NET IDE: 154. Visual Studio - .NET Core App 실행 시 dotnet.exe 실행 화면만 나오는 문제
12427정성태11/24/202010110.NET Framework: 975. .NET Core를 직접 호스팅해 (runtimeconfig.json 없이) EXE만 배포해 실행파일 다운로드1
12426정성태11/24/20208717오류 유형: 685. WinDbg Preview - error InitTypeRead
12425정성태11/24/20209771VC++: 141. Visual C++ - "Treat Warnings As Errors" 옵션이 꺼져 있는데도 일부 경고가 에러 처리되는 경우
12424정성태11/24/202010201VC++: 140. C++의 연산자 동의어(operator synonyms), 대체 토큰 [1]
12423정성태11/22/202011101.NET Framework: 974. C# 9.0 - (16) 제약 조건이 없는 형식 매개변수 주석(Unconstrained type parameter annotations)파일 다운로드1
12422정성태11/21/20208907.NET Framework: 973. .NET 5, .NET Framework에서만 허용하는 UnmanagedCallersOnly 사용예파일 다운로드1
12421정성태11/19/20208655.NET Framework: 972. DNNE가 출력한 NE DLL을 직접 생성하는 방법파일 다운로드1
12420정성태11/19/20207816오류 유형: 684. Visual C++ - MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
12419정성태11/19/20209033VC++: 139. Visual C++ - .NET Core의 nethost.lib와 정적 링크파일 다운로드1
12418정성태11/19/202011124오류 유형: 683. Visual C++ - error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug'파일 다운로드1
12417정성태11/19/20208519오류 유형: 682. Visual C++ - warning LNK4099: PDB '...pdb' was not found with '...lib(pch.obj)' or at '...pdb'; linking object as if no debug info
12416정성태11/19/20209795오류 유형: 681. Visual C++ - error LNK2001: unresolved external symbol _CrtDbgReport
12415정성태11/18/20209848.NET Framework: 971. UnmanagedCallersOnly 특성과 DNNE 사용파일 다운로드1
12414정성태11/18/202010910VC++: 138. x64 빌드에서 extern "C"가 아닌 경우 ___cdecl name mangling 적용 [4]파일 다운로드1
12413정성태11/17/202010618.NET Framework: 970. .NET 5 / .NET Core - UnmanagedCallersOnly 특성을 사용한 함수 내보내기파일 다운로드1
12412정성태11/16/202012861.NET Framework: 969. .NET Framework 및 .NET 5 - UnmanagedCallersOnly 특성 사용파일 다운로드1
12411정성태11/12/20209808오류 유형: 680. C# 9.0 - Error CS8889 The target runtime doesn't support extensible or runtime-environment default calling conventions.
12410정성태11/12/20209759디버깅 기술: 174. windbg - System.TypeLoadException 예외 분석 사례
12409정성태11/12/202011165.NET Framework: 968. C# 9.0의 Function pointer를 이용한 함수 주소 구하는 방법파일 다운로드1
... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...