Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ dependencies {
// noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_version"
api 'io.spokestack:spokestack-android:10.0.0'
api 'io.spokestack:spokestack-android:11.0.0'

// for TensorFlow Lite-powered wakeword detection and/or NLU
implementation 'org.tensorflow:tensorflow-lite:2.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ class SpokestackAdapter(sendFunc:(event: String, data: WritableMap) -> Unit):io.
reactEvent.putString("url", event.ttsResponse.audioUri.toString())
sendEvent("synthesize", reactEvent)
}
TTSEvent.Type.PLAYBACK_COMPLETE -> {
TTSEvent.Type.PLAYBACK_STARTED -> {
reactEvent.putBoolean("playing", true)
sendEvent("play", reactEvent)
}
TTSEvent.Type.PLAYBACK_STOPPED -> {
reactEvent.putBoolean("playing", false)
sendEvent("play", reactEvent)
}
TTSEvent.Type.PLAYBACK_COMPLETE -> {
// Playback is not pause-able in iOS
// so this event does not exist there.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about the semantics of the events here. Can playback not be interrupted on iOS by the system giving audio focus to another app (e.g. the phone)?

In my mind, if playback can't be paused on iOS, it would be the PLAYBACK_STOPPED event that doesn't exist there, not PLAYBACK_COMPLETE.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can playback not be interrupted on iOS by the system giving audio focus to another app (e.g. the phone)?

Only if that app took over the audio session. Audio can keep playing in the background as well if the user sets the right category and category options, since AudioSession handling is left to the user. While that is something we can know, it is not something currently tracked with an event. But you may be right that the iOS event is more like stopped than complete.

Log.d(logTag, "Playback has completed")
}
TTSEvent.Type.ERROR -> {
reactEvent.putString("error", "TTS error: " + event.error.localizedMessage)
sendEvent("error", reactEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,6 @@ class SpokestackModule(private val reactContext: ReactApplicationContext): React
val response = AudioResponse(uri)
audioPlayer.audioReceived(response)

/* TODO: Change this to a playback started listener when spokestack-android supports it. */
val reactEvent = Arguments.createMap()
reactEvent.putBoolean("playing", true)
sendEvent("play", reactEvent)

// Resolve RN promise
promise.resolve(null)
promises.remove(SpokestackPromise.SPEAK)
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react'
import checkPermission from './checkPermission'

const noTranscriptMessage =
'Press the listening button and speak to record a message for speech playback'
'Press the "Listen" button and speak to record a message for speech playback'

export default function App() {
const [listening, setListening] = React.useState(false)
Expand Down