Skip to content

Commit

Permalink
fix: tts doesn't work (closes #442)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Sep 21, 2024
1 parent 5f20c0a commit 3a41689
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 312 deletions.
263 changes: 0 additions & 263 deletions .idea/other.xml

This file was deleted.

48 changes: 0 additions & 48 deletions app/src/main/java/com/bnyro/translate/ui/components/TTSButton.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.filled.DoneAll
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.filled.VolumeUp
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -46,6 +47,7 @@ import com.bnyro.translate.R
import com.bnyro.translate.db.obj.Language
import com.bnyro.translate.ui.models.TranslationModel
import com.bnyro.translate.util.Preferences
import com.bnyro.translate.util.SpeechHelper

@Composable
fun TranslationField(
Expand Down Expand Up @@ -122,7 +124,19 @@ fun TranslationField(
}
)

TTSButton(translationModel, text, language.code)
if (translationModel.engine.supportsAudio) {
StyledIconButton(
imageVector = Icons.Default.VolumeUp
) {
translationModel.playAudio(language.code, text)
}
} else if (SpeechHelper.ttsAvailable) {
StyledIconButton(
imageVector = Icons.Default.VolumeUp
) {
SpeechHelper.speak(context, text, language.code)
}
}
}
}

Expand Down

0 comments on commit 3a41689

Please sign in to comment.