Feature/audio #9
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
This pull request introduces audio recording and streaming capabilities to the application, enabling real-time translation of spoken language. This feature allows users to speak into their device's microphone, have their speech transcribed and translated, and see the translated text displayed in the app.
Approach
The approach taken involves the following key components:
AudioSourceto handle audio recording from the device's microphone.TranslationSourceto manage the connection to the translation service via Socket.IO.MainViewModelto manage the application's state, including audio streaming, language selection, and translation results.MainActivityto display the translated text and provide controls for language selection and toggling the audio stream.updateSpeakerfunction inMainViewModel.What's in the PR?
AudioSourceto handle audio recording in a much more robust way. It now includes self-sufficient cleanup features and uses a coroutine scope provided by the caller to prevent leaksTranslationRepositoryintoTranslationSource, as that class isn't really a repository right nowMainViewModelto use lambdas for reacting to audio data callbacks for each speakerMainActivityOther changes
lifecycle-livedata-ktxdependency, as it is no longer neededMainViewModel,TranslationSourceandAudioStreamingStateclasses