Skip to content

Commit

Permalink
Merge pull request #3003 from PeterBowman/speech-llm-bindings
Browse files Browse the repository at this point in the history
Register bindings for new device interfaces
  • Loading branch information
randaz81 authored Aug 16, 2023
2 parents 6461d3e + 689b409 commit 54d9804
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
49 changes: 48 additions & 1 deletion bindings/yarp.i
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@
%include <stdint.i>
%include <std_vector.i>

// Try to translate std::string to native equivalents
// Try to translate std::string and std::pair to native equivalents
%include "std_string.i"
%include "std_pair.i"

#if defined(SWIGCSHARP)
// Get .NET pointers instead of swig generated types (useful when dealing with images)
Expand Down Expand Up @@ -427,6 +428,9 @@ MAKE_COMMS(Bottle)
%include <yarp/dev/IRemoteVariables.h>
%include <yarp/dev/IPidControl.h>
%include <yarp/dev/IPositionDirect.h>
%include <yarp/dev/ISpeechSynthesizer.h>
%include <yarp/dev/ISpeechTranscription.h>
%include <yarp/dev/ILLM.h>
%include <yarp/dev/MultipleAnalogSensorsInterfaces.h>

#ifndef YARP_NO_DEPRECATED // Since YARP 3.5.0
Expand All @@ -440,6 +444,8 @@ MAKE_COMMS(Bottle)
%template(SVector) std::vector<std::string>;
%template(IVector) std::vector<int>;
%template(ShortVector) std::vector<short int>;
%template() std::pair<std::string, std::string>;
%template(SPairVector) std::vector<std::pair<std::string, std::string>>;

#ifdef SWIGMATLAB
// Extend IVector for handling conversion of vectors from and to Matlab
Expand Down Expand Up @@ -818,6 +824,9 @@ typedef yarp::os::BufferedPort<ImageRgbFloat> BufferedPortImageRgbFloat;
CAST_POLYDRIVER_TO_INTERFACE(IPositionDirect)
CAST_POLYDRIVER_TO_INTERFACE(IRemoteVariables)
CAST_POLYDRIVER_TO_INTERFACE(IAxisInfo)
CAST_POLYDRIVER_TO_INTERFACE(ISpeechSynthesizer)
CAST_POLYDRIVER_TO_INTERFACE(ISpeechTranscription)
CAST_POLYDRIVER_TO_INTERFACE(ILLM)

// These views are currently disabled in SWIG + java generator since they are
// useless without the EXTENDED_ANALOG_SENSOR_INTERFACE part.
Expand Down Expand Up @@ -1543,6 +1552,44 @@ typedef yarp::os::BufferedPort<ImageRgbFloat> BufferedPortImageRgbFloat;
}
}

%extend yarp::dev::ISpeechSynthesizer {
bool getLanguage(std::vector<string>& language) {
return self->getLanguage(language[0]);
}

bool getVoice(std::vector<string>& voice) {
return self->getVoice(voice[0]);
}

bool getSpeed(std::vector<double>& speed) {
return self->getSpeed(speed[0]);
}

bool getPitch(std::vector<double>& pitch) {
return self->getPitch(pitch[0]);
}
}

%extend yarp::dev::ISpeechTranscription {
bool getLanguage(std::vector<string>& language) {
return self->getLanguage(language[0]);
}

bool transcribe(const yarp::sig::Sound& sound, std::vector<string>& transcription, std::vector<double>& score) {
return self->transcribe(sound, transcription[0], score[0]);
}
}

%extend yarp::dev::ILLM {
bool readPrompt(std::vector<string>& oPropmt) {
return self->readPrompt(oPropmt[0]);
}

bool ask(const std::string& question, std::vector<string>& answer) {
return self->ask(question, answer[0]);
}
}

// This is part is currently broken in SWIG + java generator since SWIG 3.0.3
// (last swig version tested: 3.0.12)
// See also https://github.com/robotology/yarp/issues/1770
Expand Down
3 changes: 3 additions & 0 deletions src/libYARP_dev/src/yarp/dev/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <yarp/dev/ServiceInterfaces.h>
#include <yarp/dev/IWrapper.h>
#include <yarp/dev/IMultipleWrapper.h>
#include <yarp/dev/ISpeechSynthesizer.h>
#include <yarp/dev/ISpeechTranscription.h>
#include <yarp/dev/ILLM.h>

#ifndef YARP_NO_DEPRECATED // since YARP 3.5
#define YARP_INCLUDING_DEPRECATED_HEADER_YARP_DEV_FRAMEGRABBER_H_ON_PURPOSE
Expand Down

0 comments on commit 54d9804

Please sign in to comment.