Skip to content

Commit

Permalink
Rename IDL libraries (drop suffix)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Aug 31, 2023
1 parent 349a097 commit 89473c4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 38 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})

# Enabling coverage.
option(ENABLE_coverage "Choose if you want to enable coverage collection" OFF)

if(ENABLE_coverage)
# List supported compilers.
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
endif()

# Create targets if specific requirements are satisfied.
include(CMakeDependentOption)

Expand Down
12 changes: 6 additions & 6 deletions bindings/roboticslab_speech.i
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// enable polymorphism in Python-derived classes
%module(directors="1") "roboticslab_speech"
%feature("director") roboticslab::TextToSpeechIDL;
%feature("director") roboticslab::SpeechRecognitionIDL;
%feature("director") roboticslab::SpeechSynthesis;
%feature("director") roboticslab::SpeechRecognition;

// correctly handle std::int16_t and std::vector<std::string> (in help() method)
%include "stdint.i"
Expand All @@ -21,9 +21,9 @@

%{
#include "yarp/os/Type.h" // incomplete type due to a forward declaration in PortReader.h
#include "TextToSpeechIDL.h"
#include "SpeechRecognitionIDL.h"
#include "SpeechSynthesis.h"
#include "SpeechRecognition.h"
%}

%include "TextToSpeechIDL.h"
%include "SpeechRecognitionIDL.h"
%include "SpeechSynthesis.h"
%include "SpeechRecognition.h"
4 changes: 2 additions & 2 deletions examples/cpp/espeakClientExample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <yarp/os/RpcClient.h>
#include <yarp/os/SystemClock.h>

#include <TextToSpeechIDL.h>
#include <SpeechSynthesis.h>

constexpr auto DEFAULT_REMOTE_PORT = "/tts";

Expand Down Expand Up @@ -44,7 +44,7 @@ int main(int argc, char * argv[])
return 1;
}

roboticslab::TextToSpeechIDL tts;
roboticslab::SpeechSynthesis tts;
tts.yarp().attachAsClient(client);

yInfo() << "Connected to remote Espeak server";
Expand Down
2 changes: 1 addition & 1 deletion examples/python/espeakClientExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
print('Unable to connect to remote server port %s' % args.remote)
raise SystemExit

tts = speech.TextToSpeechIDL()
tts = speech.SpeechSynthesis()
tts.yarp().attachAsClient(client)

tts.setLanguage('mb-en1')
Expand Down
6 changes: 3 additions & 3 deletions libraries/Espeak/Espeak.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __ESPEAK_HPP__
#define __ESPEAK_HPP__

#include "TextToSpeechIDL.h"
#include "SpeechSynthesis.h"

namespace roboticslab
{
Expand All @@ -16,9 +16,9 @@ namespace roboticslab

/**
* @ingroup Espeak
* @brief Implements TextToSpeechIDL.
* @brief Implements SpeechSynthesis.
*/
class Espeak : public TextToSpeechIDL
class Espeak : public SpeechSynthesis
{
public:

Expand Down
4 changes: 2 additions & 2 deletions libraries/SpeechIDL/speech.thrift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace yarp roboticslab

service TextToSpeechIDL
service SpeechSynthesis
{
/**
* set the speech langauge
Expand Down Expand Up @@ -65,7 +65,7 @@ service TextToSpeechIDL
bool checkSayDone();
}

service SpeechRecognitionIDL
service SpeechRecognition
{
/**
* configure a dictionary
Expand Down
26 changes: 13 additions & 13 deletions programs/speechRecognition/speechRecognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@

from abc import ABC, abstractmethod

class ResponderFactory(ABC):
class TranscriberFactory(ABC):
@abstractmethod
def create(self, stream):
pass

class PocketSphinxResponderFactory(ResponderFactory):
class PocketSphinxTranscriberFactory(TranscriberFactory):
def __init__(self, device, dictionary, language, rf):
self.device = device
self.dictionary = dictionary
self.language = language
self.rf = rf

def create(self, stream):
return PocketSphinxSpeechRecognitionResponder(stream, self.device, self.dictionary, self.language, self.rf)
return PocketSphinxSpeechRecognitionTranscriber(stream, self.device, self.dictionary, self.language, self.rf)

class VoskResponderFactory(ResponderFactory):
class VoskTranscriberFactory(TranscriberFactory):
def __init__(self, device, model):
self.device = device
self.model = model

def create(self, stream):
return VoskSpeechRecognitionResponder(stream, self.device, self.model)
return VoskSpeechRecognitionTranscriber(stream, self.device, self.model)

class SpeechRecognitionResponder(roboticslab_speech.SpeechRecognitionIDL):
class SpeechRecognitionTranscriber(roboticslab_speech.SpeechRecognition):
def __init__(self, stream, device):
super().__init__()
self.stream = stream
Expand Down Expand Up @@ -103,7 +103,7 @@ def unmuteMicrophone(self):
def transcribe(self, frame):
pass

class PocketSphinxSpeechRecognitionResponder(SpeechRecognitionResponder):
class PocketSphinxSpeechRecognitionTranscriber(SpeechRecognitionTranscriber):
def __init__(self, stream, device, dictionary, language, rf):
super().__init__(stream, device)
self.rf = rf
Expand Down Expand Up @@ -155,7 +155,7 @@ def transcribe(self, frame):
return True, hyp.hypstr
return False, None

class VoskSpeechRecognitionResponder(SpeechRecognitionResponder):
class VoskSpeechRecognitionTranscriber(SpeechRecognitionTranscriber):
def __init__(self, stream, device, model):
super().__init__(stream, device)

Expand Down Expand Up @@ -231,13 +231,13 @@ def int_or_str(text):
print('Dictionary and language must be specified for PocketSphinx')
raise SystemExit

responder_factory = PocketSphinxResponderFactory(args.device, args.dictionary, args.language, rf)
transcriber_factory = PocketSphinxTranscriberFactory(args.device, args.dictionary, args.language, rf)
elif args.backend == 'vosk':
if args.model is None:
print('Model must be specified for Vosk')
raise SystemExit

responder_factory = VoskResponderFactory(args.device, args.model)
transcriber_factory = VoskTranscriberFactory(args.device, args.model)
else:
print('Backend not available, must be one of: %s' % ', '.join(BACKENDS))
raise SystemExit
Expand Down Expand Up @@ -265,12 +265,12 @@ def int_or_str(text):
dtype='int16',
channels=1,
callback=lambda indata, frames, time, status: q.put(bytes(indata))) as stream:
responder = responder_factory.create(stream)
responder.yarp().attachAsServer(configPort)
transcriber = transcriber_factory.create(stream)
transcriber.yarp().attachAsServer(configPort)

while True:
frame = q.get()
isPartial, transcription = responder.transcribe(frame)
isPartial, transcription = transcriber.transcribe(frame)

if transcription:
if not isPartial:
Expand Down
2 changes: 1 addition & 1 deletion programs/speechSynthesis/speechSynthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

PLAY_PROGRAMS = ['paplay', 'play -q', 'aplay -q']

class TextToSpeechResponder(roboticslab_speech.TextToSpeechIDL):
class TextToSpeechResponder(roboticslab_speech.SpeechSynthesis):
def __init__(self, engine):
super().__init__()
self.engine = engine
Expand Down

0 comments on commit 89473c4

Please sign in to comment.