Skip to content

Commit 4d9ca0d

Browse files
Merge pull request #333 from Ayush0Chaudhary/remove-asterisks-from-speech
Refactor: Remove asterisks from spoken text
2 parents a24efaa + b38464c commit 4d9ca0d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

app/src/main/java/com/blurr/voice/utilities/SpeechCoordinator.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,25 @@ class SpeechCoordinator private constructor(private val context: Context) {
4242
* @param text The text to speak
4343
*/
4444
suspend fun speakText(text: String) {
45+
val cleanedText = text.replace("*", "")
4546
speechMutex.withLock {
4647
try {
4748
if (isListening) {
48-
Log.d(TAG, "Stopping STT before speaking: $text")
49+
Log.d(TAG, "Stopping STT before speaking: $cleanedText")
4950
sttManager.stopListening()
5051
isListening = false
5152
delay(250) // Brief pause to ensure STT is fully stopped
5253
}
5354

5455
isSpeaking = true
55-
Log.d(TAG, "Starting TTS: $text")
56+
Log.d(TAG, "Starting TTS: $cleanedText")
5657

5758
// This is a suspend call that will wait until TTS is actually done.
58-
ttsManager.speakText(text)
59+
ttsManager.speakText(cleanedText)
5960

6061
// FIXED: The inaccurate, estimated delay has been removed!
6162

62-
Log.d(TAG, "TTS completed: $text")
63+
Log.d(TAG, "TTS completed: $cleanedText")
6364

6465
} finally {
6566
// Ensure the speaking flag is always reset
@@ -73,22 +74,23 @@ class SpeechCoordinator private constructor(private val context: Context) {
7374
* @param text The text to speak to the user
7475
*/
7576
suspend fun speakToUser(text: String) {
77+
val cleanedText = text.replace("*", "")
7678
speechMutex.withLock {
7779
try {
7880
if (isListening) {
79-
Log.d(TAG, "Stopping STT before speaking to user: $text")
81+
Log.d(TAG, "Stopping STT before speaking to user: $cleanedText")
8082
sttManager.stopListening()
8183
isListening = false
8284
delay(250) // Brief pause
8385
}
8486

8587
isSpeaking = true
86-
Log.d(TAG, "Starting TTS to user: $text")
88+
Log.d(TAG, "Starting TTS to user: $cleanedText")
8789

88-
ttsManager.speakToUser(text)
90+
ttsManager.speakToUser(cleanedText)
8991

9092

91-
Log.d(TAG, "TTS to user completed: $text")
93+
Log.d(TAG, "TTS to user completed: $cleanedText")
9294

9395
} finally {
9496
// Ensure the speaking flag is always reset

0 commit comments

Comments
 (0)