-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Voice To Content] AudioRecorder improvements #20915
Conversation
5ede5bc
to
5fda76b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pantstamp - I like the improvements. 👏 I have two thoughts. These can definitely be overkill thoughts on my part and I am NOT requesting changes. Just curious to hear your thoughts.
💡
(1) Adding an initialization method that takes an interface for configurable parameters such as maxFileSize, maxDuration, storeInMemory, and recordingFileName. This approach follows the Strategy design pattern, allowing different recording configurations to be easily swapped in and out. Something like this:
interface RecordingStrategy {
val maxFileSize: Long
val maxDuration: Int
val storeInMemory: Boolean
val recordingFileName: String
}
and then a VoiceToContentRecordingStrategy
.
This could work with interfaces or sealed classes.
sealed class RecordingStrategy {
data class VoiceToContentRecordingStrategy(
val maxFileSize: Long = xxx,
val maxDuration: Int = yyy,
val recordingFileName: String = "asdfas",
val storeInMemory: Boolean = true
) : RecordingStrategy()
}
(2) Using a sealed class to represent the different outcomes of the recording process instead of a plain String. This method allows for clear differentiation between success and error states and makes the code more maintainable and expressive. Ignore my too long method names and such.
sealed class AudioRecorderFinishedResponse {
data class Success(val fileNameWithPath: String) : AudioRecorderFinishedResponse()
data class Error(val errorMessage: String) : AudioRecorderFinishedResponse()
}
You can even use a flow to return the response
wdyt? Am I nuts?
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
Generated by 🚫 Danger |
Quality Gate passedIssues Measures |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #20915 +/- ##
==========================================
- Coverage 40.96% 40.94% -0.02%
==========================================
Files 1517 1518 +1
Lines 69516 69547 +31
Branches 11468 11473 +5
==========================================
Hits 28474 28474
- Misses 38456 38487 +31
Partials 2586 2586 ☔ View full report in Codecov by Sentry. |
Both ideas are great @zwarm ! I pushed some extra commits that include these implementations. Thank you!!! |
Fixes #
https://github.com/Automattic/wordpress-mobile/issues/93
https://github.com/Automattic/wordpress-mobile/issues/94
https://github.com/Automattic/wordpress-mobile/issues/95
https://github.com/Automattic/wordpress-mobile/issues/96
This PR introduces some minor improvements for the AudioRecorder like better error handling, recording params special values, threshold values to ensure that recording constraints are met.
To Test:
Please review the code and follow the steps below to ensure that nothing is broken.
✅ Verify the microphone disappears, "Assistant Feature Returned Successfully" text is shown quickly, and then the text changes to what you have said.
Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR Submission Checklist:
RELEASE-NOTES.txt
if necessary.Testing Checklist (strike-out the not-applying and unnecessary ones):