-1

目前我正在使用创建一个 STT 应用程序

  • NodeJS v16.x
  • microsoft-cognitiveservices-speech-sdk v1.17.0

我在该地区创建了一个 azure Speech Cognitive 资源westeurope并验证了密钥是否正确。

现在我正在使用以下代码来执行语音识别:


class RecognizerAzure {

  recognize(){
    this.audioFormat = AudioStreamFormat.getWaveFormatPCM(sampleRate, 16, 1)
    this.pushStream = AudioInputStream.createPushStream(this.audioFormat)
    this.audioConfig = AudioConfig.fromStreamInput(this.pushStream)
    this.speechConfig = SpeechConfig.fromSubscription(
      '*************',
      'westeurope'
    )
    this.speechConfig.speechRecognitionLanguage = "en_US"

    this.recognizer = new SpeechRecognizerMicrosoftAzure(
      this.speechConfig,
      this.audioConfig
    )

    this.recognizer.startContinuousRecognitionAsync(() => {
      if (this.recognizer) {
        console.debug(inspect(this.recognizer))
        this.recognizer.canceled = console.log
      }
    }, this.logger.warn)
  }

然后识别器将只记录一个带有消息的事件Unable to contact server. StatusCode: 1006, undefined Reason: Unsupported type: object at: (shallow)。我根据 azure 文档创建了一个语音服务,并按照 Azure 门户中的示例实现中的定义实现了此代码。

遗憾的是,此错误消息对我没有太大帮助,我也无法在 Azure 知识库中找到任何内容。

其他人有同样的问题吗?

4

1 回答 1

0

我可以通过使用我的 package.json 明确设置手动分辨率来解决这个问题。这似乎源于 asn1.js 中使用的证书方法。谢谢你的帮助。我在那里添加了这一行:

{
  "resolutions": {
    "microsoft-cognitiveservices-speech-sdk/**/asn1.js": "5.4.1"
  }
}
于 2022-02-03T15:13:36.640 回答