Я пытаюсь реализовать систему оценки произношения с помощью Azure JS SDK (см. документ).
Я получаю следующую ошибку в консоли:
"Не удалось десериализовать речевой контекст. Код ошибки веб-сокета: 1007"
Вот моя реализация:assessPronunciation(fileUrl) {
const speechConfig = window.SpeechSDK.SpeechConfig.fromSubscription("xxx", "westeurope");
speechConfig.speechRecognitionLanguage = "en-GB";
// Fetch the WAV file and create an AudioConfig
fetch(fileUrl)
.then(response => response.blob())
.then(blob => {
// Convert the blob to a File object
const file = new File([blob], "audio.wav", { type: "audio/wav" });
// Create an AudioConfig using the File object
const audioConfig = window.SpeechSDK.AudioConfig.fromWavFileInput(file);
var pronunciationAssessmentConfig = new window.SpeechSDK.PronunciationAssessmentConfig({
referenceText: "Hello this is a test",
gradingSystem: "HundredMark",
granularity: "Phoneme"
});
var speechRecognizer = new window.SpeechSDK.SpeechRecognizer(speechConfig, audioConfig);
pronunciationAssessmentConfig.applyTo(speechRecognizer);
speechRecognizer.sessionStarted = (s, e) => {
console.log(`SESSION ID: ${e.sessionId}`);
};
pronunciationAssessmentConfig.applyTo(speechRecognizer);
speechRecognizer.recognizeOnceAsync(
function(speechRecognitionResult) {
if (speechRecognitionResult.reason === window.SpeechSDK.ResultReason.RecognizedSpeech) {
// The pronunciation assessment result as a Speech SDK object
var pronunciationAssessmentResult = SpeechSDK.PronunciationAssessmentResult.fromResult(speechRecognitionResult);
console.log("pronunciationAssessmentResult", pronunciationAssessmentResult);
// The pronunciation assessment result as a JSON string
var pronunciationAssessmentResultJson = speechRecognitionResult.properties.getProperty(SpeechSDK.PropertyId.SpeechServiceResponse_JsonResult);
console.log("pronunciationAssessmentResultJson", pronunciationAssessmentResultJson);
} else {
console.error("Speech not recognized. Reason:", speechRecognitionResult);
}
},
function(error) {
console.error("Error during recognition:", error);
if (error instanceof window.SpeechSDK.SpeechRecognitionCanceledEventArgs) {
console.error("Recognition canceled. Reason:", error.reason);
console.error("Error details:", error.errorDetails);
}
}
);
})
.catch(error => {
console.error("Error fetching WAV file:", error);
});
}
< /code>
Я проверил запись (FileUrl), и это рабочий файл WAV, как и ожидалось. < /p>
Есть идеи, в чем проблема? Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/793 ... text-error
Оценке произношения Azure не удалось десериализовать ошибку контекста речи ⇐ Javascript
Форум по Javascript
1737815522
Anonymous
Я пытаюсь реализовать систему оценки произношения с помощью Azure JS SDK (см. документ).
Я получаю следующую ошибку в консоли:
"Не удалось десериализовать речевой контекст. Код ошибки веб-сокета: 1007"
Вот моя реализация:assessPronunciation(fileUrl) {
const speechConfig = window.SpeechSDK.SpeechConfig.fromSubscription("xxx", "westeurope");
speechConfig.speechRecognitionLanguage = "en-GB";
// Fetch the WAV file and create an AudioConfig
fetch(fileUrl)
.then(response => response.blob())
.then(blob => {
// Convert the blob to a File object
const file = new File([blob], "audio.wav", { type: "audio/wav" });
// Create an AudioConfig using the File object
const audioConfig = window.SpeechSDK.AudioConfig.fromWavFileInput(file);
var pronunciationAssessmentConfig = new window.SpeechSDK.PronunciationAssessmentConfig({
referenceText: "Hello this is a test",
gradingSystem: "HundredMark",
granularity: "Phoneme"
});
var speechRecognizer = new window.SpeechSDK.SpeechRecognizer(speechConfig, audioConfig);
pronunciationAssessmentConfig.applyTo(speechRecognizer);
speechRecognizer.sessionStarted = (s, e) => {
console.log(`SESSION ID: ${e.sessionId}`);
};
pronunciationAssessmentConfig.applyTo(speechRecognizer);
speechRecognizer.recognizeOnceAsync(
function(speechRecognitionResult) {
if (speechRecognitionResult.reason === window.SpeechSDK.ResultReason.RecognizedSpeech) {
// The pronunciation assessment result as a Speech SDK object
var pronunciationAssessmentResult = SpeechSDK.PronunciationAssessmentResult.fromResult(speechRecognitionResult);
console.log("pronunciationAssessmentResult", pronunciationAssessmentResult);
// The pronunciation assessment result as a JSON string
var pronunciationAssessmentResultJson = speechRecognitionResult.properties.getProperty(SpeechSDK.PropertyId.SpeechServiceResponse_JsonResult);
console.log("pronunciationAssessmentResultJson", pronunciationAssessmentResultJson);
} else {
console.error("Speech not recognized. Reason:", speechRecognitionResult);
}
},
function(error) {
console.error("Error during recognition:", error);
if (error instanceof window.SpeechSDK.SpeechRecognitionCanceledEventArgs) {
console.error("Recognition canceled. Reason:", error.reason);
console.error("Error details:", error.errorDetails);
}
}
);
})
.catch(error => {
console.error("Error fetching WAV file:", error);
});
}
< /code>
Я проверил запись (FileUrl), и это рабочий файл WAV, как и ожидалось. < /p>
Есть идеи, в чем проблема? Спасибо.
Подробнее здесь: [url]https://stackoverflow.com/questions/79386909/azure-pronunciation-assessment-could-not-deserialize-speech-context-error[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия