22 lines
625 B
Go
22 lines
625 B
Go
// Package tts speaks text aloud with the system's speech synthesizer, on
|
|||
|
|
// phones. It is a thin Go binding over a small Android TextToSpeech plugin.
|
||
|
|
package tts
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"github.com/egoist/mygo"
|
||
|
|
)
|
||
|
|
|
||
|
|
const pluginID = "tts"
|
||
|
|
|
||
|
|
// Speak reads text aloud, stopping any speech in progress. On desktops it
|
||
|
|
// reports errors.ErrUnsupported.
|
||
|
|
func Speak(ctx context.Context, text string) error {
|
||
|
|
return mygo.Native(pluginID).Call(ctx, "speak", map[string]string{"text": text}, nil)
|
||
|
|
}
|
||
|
|
|
||
|
|
// Stop stops any speech in progress.
|
||
|
|
func Stop() error {
|
||
|
|
return mygo.Native(pluginID).Call(context.Background(), "stop", nil, nil)
|
||
|
|
}
|