6#ifndef _USE_MATH_DEFINES
7#define _USE_MATH_DEFINES
34 if(config.
check(
"__offline"))
36 m_offline = config.
find(
"__offline").asInt32() == 1;
44 m_audioConfig.set_encoding(google::cloud::speech::v1::RecognitionConfig::LINEAR16);
46 m_client = std::make_shared<google::cloud::speech_v1::SpeechClient>(google::cloud::speech_v1::MakeSpeechConnection());
58 if(language ==
"auto")
65 m_audioConfig.set_language_code(language);
71 language = m_audioConfig.language_code();
88 google::cloud::speech::v1::RecognitionAudio
audio;
93 auto response = m_client->Recognize(m_audioConfig,
audio);
102 for(
int i=0; i<response->results_size(); i++)
104 auto result = response->results(i);
106 for(
int j=0;
j<result.alternatives_size();
j++)
const yarp::os::LogComponent & GOOGLESPEECHTRANSCR()
std::string m_language_code
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
GoogleSpeechTranscription()
yarp::dev::ReturnValue setLanguage(const std::string &language="auto") override
Sets the language for speech transcription.
yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current language set for speech transcription.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue transcribe(const yarp::sig::Sound &sound, std::string &transcription, double &score) override
Performs the speech transcription.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
@ return_value_error_generic
Method was successfully executed.
A mini-server for performing network communication in the background.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
std::vector< std::reference_wrapper< audio_sample > > getNonInterleavedAudioRawData() const
Returns a serialized version of the sound, in non-interleaved format, e.g.
size_t getChannels() const
Get the number of channels of the sound.
size_t getSamples() const
Get the number of samples contained in the sound.
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.