Switch TTS from mimic to flite
This commit is contained in:
parent
ffec012ca0
commit
dabe5b0fe2
@ -8,13 +8,15 @@ Personal voice assistant written in go using DeepSpeech. This was mainly created
|
|||||||
|
|
||||||
The prerequisites for trident are:
|
The prerequisites for trident are:
|
||||||
- libdeepspeech and DeepSpeech models (speech to text)
|
- libdeepspeech and DeepSpeech models (speech to text)
|
||||||
- mimic (text to speech)
|
- flite (text to speech)
|
||||||
- go
|
- go
|
||||||
|
|
||||||
`libdeepspeech` along with its models can be found in [its github releases](https://github.com/mozilla/DeepSpeech/releases/). Be sure to download the `native_client` tarball for your platform and the `.pbmm` and `.scorer` files.
|
`libdeepspeech` along with its models can be found in [its github releases](https://github.com/mozilla/DeepSpeech/releases/). Be sure to download the `native_client` tarball for your platform and the `.pbmm` and `.scorer` files.
|
||||||
|
|
||||||
`mimic` can be installed via an [install script](https://github.com/MycroftAI/mycroft-core/blob/dev/scripts/install-mimic.sh) or its AUR package if using Arch Linux or its derivatives.
|
`flite` can be installed via your distribution's repositories:
|
||||||
|
- Debian/Ubuntu: `sudo apt install flite-dev`
|
||||||
|
- Fedora: `sudo dnf install flite-devel`
|
||||||
|
- Arch: `sudo pacman -S flite festival-us`
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
Move the previously downloaded models (`.pbmm` and `.scorer`) into this repo as `deepspeech.pbmm` and `deepspeech.scorer`. Then, follow the next steps.
|
Move the previously downloaded models (`.pbmm` and `.scorer`) into this repo as `deepspeech.pbmm` and `deepspeech.scorer`. Then, follow the next steps.
|
||||||
|
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/asticode/go-astideepspeech v0.10.0
|
github.com/asticode/go-astideepspeech v0.10.0
|
||||||
|
github.com/gen2brain/flite-go v0.0.0-20170519100317-f4df2119132c
|
||||||
github.com/gen2brain/malgo v0.10.29
|
github.com/gen2brain/malgo v0.10.29
|
||||||
github.com/pelletier/go-toml v1.9.0
|
github.com/pelletier/go-toml v1.9.0
|
||||||
github.com/rs/zerolog v1.21.0
|
github.com/rs/zerolog v1.21.0
|
||||||
|
2
go.sum
2
go.sum
@ -5,6 +5,8 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
|
|||||||
github.com/cryptix/wav v0.0.0-20180415113528-8bdace674401/go.mod h1:knK8fd+KPlGGqSUWogv1DQzGTwnfUvAi0cIoWyOG7+U=
|
github.com/cryptix/wav v0.0.0-20180415113528-8bdace674401/go.mod h1:knK8fd+KPlGGqSUWogv1DQzGTwnfUvAi0cIoWyOG7+U=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/gen2brain/flite-go v0.0.0-20170519100317-f4df2119132c h1:JBlwZJSYopoPXh0dLN9GGw750uhU08VjKKpl+uX5pE4=
|
||||||
|
github.com/gen2brain/flite-go v0.0.0-20170519100317-f4df2119132c/go.mod h1:Wv0H30ZpZPf4CrBNqgiG2S4G0CDtZWS2i87JnPtv9LI=
|
||||||
github.com/gen2brain/malgo v0.10.29 h1:bTYiUTUKJsEomNby+W0hgyLrOttUXIk4lTEnKA54iqM=
|
github.com/gen2brain/malgo v0.10.29 h1:bTYiUTUKJsEomNby+W0hgyLrOttUXIk4lTEnKA54iqM=
|
||||||
github.com/gen2brain/malgo v0.10.29/go.mod h1:zHSUNZAXfCeNsZou0RtQ6Zk7gDYLIcKOrUWtAdksnEs=
|
github.com/gen2brain/malgo v0.10.29/go.mod h1:zHSUNZAXfCeNsZou0RtQ6Zk7gDYLIcKOrUWtAdksnEs=
|
||||||
github.com/pelletier/go-toml v1.9.0 h1:NOd0BRdOKpPf0SxkL3HxSQOG7rNh+4kl6PHcBPFs7Q0=
|
github.com/pelletier/go-toml v1.9.0 h1:NOd0BRdOKpPf0SxkL3HxSQOG7rNh+4kl6PHcBPFs7Q0=
|
||||||
|
@ -21,18 +21,21 @@ package shell
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"trident"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunPlugin(program string, data map[string]interface{}) {
|
func RunPlugin(program string, data map[string]interface{}) {
|
||||||
var shell string
|
|
||||||
var ok bool
|
|
||||||
// Attempt to get shell from config, asserting as string
|
// Attempt to get shell from config, asserting as string
|
||||||
shell, ok = data["shell"].(string)
|
shell, ok := data["shell"].(string)
|
||||||
// If unsuccessful
|
// If unsuccessful
|
||||||
if !ok {
|
if !ok {
|
||||||
// Set shell to default (/bin/sh)
|
// Set shell to default (/bin/sh)
|
||||||
shell = "/bin/sh"
|
shell = "/bin/sh"
|
||||||
}
|
}
|
||||||
|
sayOutput, ok := data["sayOutput"].(bool)
|
||||||
|
if !ok {
|
||||||
|
sayOutput = false
|
||||||
|
}
|
||||||
// Create command using configured shell or default (/bin/sh)
|
// Create command using configured shell or default (/bin/sh)
|
||||||
cmd := exec.Command(shell, "-c", program)
|
cmd := exec.Command(shell, "-c", program)
|
||||||
// Set command environment to system environment
|
// Set command environment to system environment
|
||||||
@ -40,5 +43,8 @@ func RunPlugin(program string, data map[string]interface{}) {
|
|||||||
// Set command's standard error to system standard error
|
// Set command's standard error to system standard error
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
// Run command, ignoring error
|
// Run command, ignoring error
|
||||||
_ = cmd.Run()
|
output, _ := cmd.Output()
|
||||||
|
if sayOutput {
|
||||||
|
trident.Say(string(output))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
18
symbols.go
18
symbols.go
@ -18,8 +18,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/gen2brain/flite-go"
|
||||||
"github.com/traefik/yaegi/interp"
|
"github.com/traefik/yaegi/interp"
|
||||||
"os/exec"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,17 +29,7 @@ var tridentSymbols = interp.Exports{"trident": {
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
// Function to say text using mimic text-to-speech
|
// Function to say text using mimic text-to-speech
|
||||||
func Say(text string, args ...string) {
|
func Say(text string) {
|
||||||
// If mimic exists in PATH
|
voice, _ := flite.VoiceSelect("slt")
|
||||||
if _, err := exec.LookPath("mimic"); err == nil {
|
flite.TextToSpeech(text, voice, "play")
|
||||||
// Set initial argument slice to contain text
|
|
||||||
argSlice := []string{"-t", text}
|
|
||||||
// Add any additional arguments to slice
|
|
||||||
argSlice = append(argSlice, args...)
|
|
||||||
// Create and run command
|
|
||||||
exec.Command("mimic", argSlice...).Run()
|
|
||||||
} else {
|
|
||||||
// If mimic does not exist in PATH, warn user
|
|
||||||
log.Warn().Err(err).Str("text", text).Msg("Cannot perform text to speech")
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user