Replies: 1 comment
-
It appears you set the recognizer:
but, I don't see any code to create a recognizer with that name. Try using the implicit recognizer:
You may also want to use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Below is my sample code, whenever i running this code getting below errors--->
Recognize stream finished with an error: NOT_FOUND: Unable to find Recognizer
sample code --->
#include "google/cloud/speech/v2/speech_client.h"
#include "google/cloud/project.h"
#include
#include
#include
#include
#include "google/cloud/common_options.h"
namespace speech = google::cloud::speech_v2;
using namespace ::google::cloud::speech::v2;
using RecognizeStream = ::google::cloud::AsyncStreamingReadWriteRpc<StreamingRecognizeRequest,StreamingRecognizeResponse>;
using namespace std;
auto constexpr kUsage = R"""(Usage:
streaming_transcribe [--bitrate N] audio.(raw|ulaw|flac|amr|awb)
)""";
// Write the audio in 64k chunks at a time, simulating audio content arriving
// from a microphone.
void MicrophoneThreadMain(RecognizeStream& stream,std::string const& file_path) {
StreamingRecognizeRequest request;
std::ifstream file_stream(file_path, std::ios::binary);
auto constexpr kChunkSize = 32 * 1024;
std::vector chunk(kChunkSize);
while (true) {
// Read another chunk from the file.
file_stream.read(chunk.data(), chunk.size());
auto const bytes_read = file_stream.gcount();
// And write the chunk to the stream.
if (bytes_read > 0) {
request.set_audio(chunk.data(), bytes_read);
//std::cout << "Sending " << bytes_read / 1024 << "k bytes." << std::endl;
if (!stream.Write(request, grpc::WriteOptions()).get())
{
break;
}else
{
std::cout << "Sending " << bytes_read / 1024 << "k bytes." << std::endl;
}
}
if (!file_stream) {
// Done reading everything from the file, so done writing to the stream.
stream.WritesDone().get();
cout<<"done... wrting data\n";
break;
}
// Wait a second before writing the next chunk.
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
void ConfigureRecognizer(google::cloud::speech::v2::RecognizeRequest& request) {
*request.mutable_config()->add_language_codes() = "hi-IN";
request.mutable_config()->set_model("long");
*request.mutable_config()->mutable_auto_decoding_config() = {};
}
struct location {
using Type = std::string;
};
int main(int argc, char** argv) try {
// Create a Speech client with the default configuration
//auto options = ::google::cloud::Options{}.set<::google::cloud::EndpointOption>("asia-south1-speech.googleapis.com");
// auto client = google::cloud::speech_v2::SpeechClient(
//google::cloud::speech_v2::MakeSpeechConnection(options));
//auto client = speech::SpeechClient(speech::MakeSpeechConnection(options));
} catch (google::cloud::Status const& s) {
std::cerr << "Recognize stream finished with an error: " << s << "\n";
return 1;
} catch (std::exception const& ex) {
std::cerr << "Standard C++ exception thrown: " << ex.what() << "\n"
<< kUsage << "\n";
return 1;
}
Beta Was this translation helpful? Give feedback.
All reactions