23 | ⚠️ Please make sure that your runtime environment supports the latest version of Wasm GC and Exception-Handling proposals.
24 | For more information, see
https://kotl.in/wasm-help.
25 |
26 |
27 |
28 | - For Chrome and Chromium-based browsers (Edge, Brave etc.), it should just work since version 119.
29 | - For Firefox 120 it should just work.
30 | - For Firefox 119:
31 |
32 | - Open about:config in the browser.
33 | - Enable javascript.options.wasm_gc.
34 | - Refresh this page.
35 |
36 |
37 |
38 |
39 |
40 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/tts/src/commonMain/kotlin/nl/marc_apps/tts/errors/TextToSpeechSynthesisErrors.kt:
--------------------------------------------------------------------------------
1 | package nl.marc_apps.tts.errors
2 |
3 | private const val defaultErrorMessage = "Error while trying to synthesise text input"
4 |
5 | /** Error that is thrown when synthesising text input fails. */
6 | sealed class TextToSpeechSynthesisError(
7 | message: String? = defaultErrorMessage,
8 | cause: Throwable? = null
9 | ) : Exception(message, cause)
10 |
11 | /** Error that is thrown when synthesising text input fails because of the user input. */
12 | class TextToSpeechInputError(
13 | message: String? = defaultErrorMessage,
14 | cause: Throwable? = null
15 | ) : TextToSpeechSynthesisError(message, cause)
16 |
17 | /** Error that is thrown when synthesising text input failed, usually when stop() or close() are called. */
18 | class TextToSpeechSynthesisInterruptedError(
19 | cause: Throwable? = null
20 | ) : TextToSpeechSynthesisError("TTS synthesis was interrupted by a call to stop() or close()", cause)
21 |
22 | /** Error that is thrown when synthesising text input fails because of the TTS engine. */
23 | sealed class TextToSpeechEngineError(
24 | message: String? = defaultErrorMessage,
25 | cause: Throwable? = null
26 | ) : TextToSpeechSynthesisError(message, cause)
27 |
28 | /** Error that is thrown when synthesising text input fails. */
29 | class UnknownTextToSpeechSynthesisError(
30 | cause: Throwable? = null
31 | ) : TextToSpeechEngineError(cause = cause)
32 |
33 | /** Error that is thrown when synthesising text input fails, because the TTS Engine crashed. */
34 | class TextToSpeechServiceFailureError(
35 | cause: Throwable? = null
36 | ) : TextToSpeechEngineError("The TTS engine crashed while processing the request", cause)
37 |
38 | /** Error that is thrown when synthesising text input fails, because something is wrong with the device audio output. */
39 | class DeviceAudioOutputError(
40 | cause: Throwable? = null
41 | ) : TextToSpeechEngineError("TTS synthesis unavailable due to device audio output error", cause)
42 |
43 | /** Error that is thrown when synthesising text input fails, because something is wrong with the network. */
44 | class TextToSpeechNetworkError(
45 | val timeout: Boolean = false,
46 | cause: Throwable? = null
47 | ) : TextToSpeechEngineError("The TTS engine requires network access, but this was not available", cause)
48 |
49 | /** Error that is thrown when synthesising text input fails, because the TTS engine has not been installed (yet). */
50 | class TextToSpeechEngineUnavailableError(
51 | cause: Throwable? = null
52 | ) : TextToSpeechEngineError("The TTS engine that should handle this request has not been installed (yet)", cause)
53 |
--------------------------------------------------------------------------------
/tts/src/commonMain/kotlin/nl/marc_apps/tts/TextToSpeechInstance.kt:
--------------------------------------------------------------------------------
1 | package nl.marc_apps.tts
2 |
3 | import kotlinx.coroutines.flow.StateFlow
4 | import nl.marc_apps.tts.experimental.ExperimentalTextToSpeechApi
5 | import nl.marc_apps.tts.experimental.ExperimentalVoiceApi
6 |
7 | /** A TTS instance. Should be [close]d when no longer in use. */
8 | interface TextToSpeechInstance : AutoCloseable {
9 | val isSynthesizing: StateFlow