I have two questions:
1 From
I did not find sample about audio stream.
2 I have replaced scriptionKey and ServiceRegion, and subscribed Speech Service, I tried this
std::string FILE_NAME = "./myVoiceIsMyPassportVerifyMe03.wav";
void recognizeSpeech() {
// Creates an instance of a speech config with specified subscription key and service region.
// Replace with your own subscription key and service region (e.g., "westus").
using namespace Microsoft::CognitiveServices::Speech::Audio;
auto config = SpeechConfig::FromSubscription("myid", "myreg");
auto audioInput = AudioConfig::FromWavFileInput(FILE_NAME);
auto recognizer = SpeechRecognizer::FromConfig(config, audioInput);
auto result = recognizer->RecognizeOnceAsync().get();
switch (result->Reason)
{
case ResultReason::RecognizedSpeech:
cout << "We recognized: " << result->Text << std::endl;
break;
case ResultReason::NoMatch:
cout << "NOMATCH: Speech could not be recognized." << std::endl;
break;
case ResultReason::Canceled:
{
auto cancellation = CancellationDetails::FromResult(result);
cout << "CANCELED: Reason=" << (int)cancellation->Reason << std::endl;
if (cancellation->Reason == CancellationReason::Error) {
cout << "CANCELED: ErrorCode= " << (int)cancellation->ErrorCode << std::endl;
cout << "CANCELED: ErrorDetails=" << cancellation->ErrorDetails << std::endl;
cout << "CANCELED: Did you update the subscription info?" << std::endl;
}
}
break;
default:
break;
}
}
but I got
CANCELED: Reason=1
CANCELED: ErrorCode= 5
CANCELED: ErrorDetails=Connection failed (no connection to the remote host). Internal error: 1. Error details: Code: 2460. SessionId: 16230b52f1a9435a97a65a0ff4dbc26e
CANCELED: Did you update the subscription info?