CatalystCode / cordova-plugin-cogsvcsspeech

Cordova plugin for Microsoft Cognitive Services speech services.
MIT License
2 stars 3 forks source link

Create abstraction that can be shared between iOS and Android approaches for STT and TTS #17

Closed rozele closed 4 years ago

rozele commented 4 years ago

Is your feature request related to a problem? Please describe.

We have two different approaches for STT and TTS using Cognitive Services on iOS vs. Android. On iOS, we're using an Ionic Native plugin, which will convert a series of native method callbacks to an Observable. On Android, we're using the JS SDK, which just has two separate event callbacks, one for "Recognizing" events and the other for "Recognized" events.

The goal would be to create an abstraction that supports both.

Describe the solution you'd like A speech service interface that can be implemented differently for iOS and Android with the following methods:

interface SpeechService {
  init(speechKey: string, speechRegion: string): void
  startListening(): Observable<{ isFinal: boolean, text: string }>
  stopListening(): Promise<void>
  speakSsml(): Promise<void>
  stopSpeaking(): Promise<void> 
}

Describe alternatives you've considered We've considered two alternatives

  1. Implement the native Cordova plugin for Android instead
  2. Push platform specific logic into the application layer

For 1., we assume over time the Speech JS SDK will work as expected on iOS, so it's good to have parallel implementations.

For 2., it's good to write an abstraction once that others can reuse in their application layer.

esgraham commented 4 years ago

How would this differ from the plugin with the Android code added (issues 9,10,11)? The plugin is an interface that uses the cordova exec functionality to call either Android code or iOS code on the respective platforms? The interface is defined in the www/cognitiveservices.js file and the ionic-native code (also under the www folder).

If we want to specify the naming conventions, lets change the title of the issue as its causing confusion.

rozele commented 4 years ago

Agree. We can close this.