Azure Speech To Text typescript problem

榮豪 蔡 6 Reputation points
2023-01-14T09:31:35.9233333+00:00

Hi Microsoft team,

I am trying to use microsoft-cognitiveservices-speech-sdk, when I build the TS, it says that.

TypeError: Cannot read properties of undefined (reading 'SpeechConfig')

Since the microsoft-cognitiveservices-speech is all written in TS, I am wondering if I miss install @type/microsoft-cognitiveservices-speech-sdk?

or Should I modify my ts-config.json, to get microsoft-cognitiveservices-speech .d.ts.

Btw, JS version of code is all working well

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,620 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Ramr-msft 17,826 Reputation points
    2023-02-02T06:11:34.67+00:00

    @榮豪 蔡 Thanks for the question, You may need to install the "@types/microsoft-cognitiveservices-speech-sdk" package in order to provide the necessary type definitions for the SDK. You can do this by running the command: "npm install @types/microsoft-cognitiveservices-speech-sdk"

    You should also check that the type definition file for the package is being properly included in your TypeScript project. Make sure that you have the correct path for the package in your "tsconfig.json" file under "include" or "files" and check the version of the package and the type definition package match.

    Also it would be helpful if you can share your ts-config.json file so we can assist you better.


  2. Ethan 0 Reputation points
    2023-08-03T17:14:01.9533333+00:00

    Because the "microsoft-cognitiveservices-speech-sdk" module don't have a default-export, so you should write this below

    import * as sdk from "microsoft-cognitiveservices-speech-sdk"
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.