Skip to content

Commit

Permalink
add -e (emotion) option
Browse files Browse the repository at this point in the history
  • Loading branch information
shinshin86 committed Dec 3, 2023
1 parent 1d2bb9b commit 11224f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Execute the following command to speak the string passed as an argument.

```
vpeak こんにちは!
# option (narrator: Japanese Female 1, emotion: happy)
vpeak -n f1 -e happy "こんにちは"
```

Converts all text files(`.txt`) in the directory specified by the `-d` option to audio files (`.wav`).
Expand Down Expand Up @@ -36,7 +39,7 @@ Currently only **M1 or later(arm64) mac** are supported

### VOICEPEAK
VOICEPEAK must be updated to the latest version in order to use vpeak.
I am testing with 1.2.2.
I am testing with 1.2.7.


## License
Expand Down
25 changes: 25 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func convertWavExt(filename string) string {
func main() {
dirOpt := flag.String("d", "", "Directory to read files from")
narratorOpt := flag.String("n", "", "Specify the narrator. See below for options.")
emotionOpt := flag.String("e", "", "Specify the emotion. See below for options.")

flag.Usage = func() {
fmt.Printf("Usage: %s [OPTIONS] <text>\n", os.Args[0])
Expand All @@ -50,6 +51,11 @@ func main() {
fmt.Println(" m2: Japanese Male 2")
fmt.Println(" m3: Japanese Male 3")
fmt.Println(" c: Japanese Female Child")
fmt.Println("\nEmotion options:")
fmt.Println(" happy")
fmt.Println(" fun")
fmt.Println(" angry")
fmt.Println(" sad")
}

help := flag.Bool("help", false, "Show help")
Expand All @@ -75,6 +81,13 @@ func main() {
"c": "Japanese Female Child",
}

emotionMap := map[string]string{
"happy": "happy=100",
"fun": "fun=100",
"angry": "angry=100",
"sad": "sad=100",
}

if *dirOpt == "" {
text := flag.Args()[0]
options := []string{"-s", text}
Expand All @@ -84,6 +97,12 @@ func main() {
log.Fatalf("Invalid narrator option: %s", *narratorOpt)
}

if emotion, ok := emotionMap[*emotionOpt]; ok {
options = append([]string{"--emotion", emotion}, options...)
} else if *emotionOpt != "" {
log.Fatalf("Invalid emotion option: %s", *emotionOpt)
}

cmd1 := vpCmd(options)
err := cmd1.Run()
if err != nil {
Expand Down Expand Up @@ -125,6 +144,12 @@ func main() {
log.Fatalf("Invalid narrator option: %s", *narratorOpt)
}

if emotion, ok := emotionMap[*emotionOpt]; ok {
options = append([]string{"--emotion", emotion}, options...)
} else if *emotionOpt != "" {
log.Fatalf("Invalid emotion option: %s", *emotionOpt)
}

cmd1 := vpCmd(options)
err = cmd1.Run()
if err != nil {
Expand Down

0 comments on commit 11224f3

Please sign in to comment.