forked from amitybell/piper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiper_test.go
74 lines (65 loc) · 1.75 KB
/
piper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package piper
import (
"os"
"testing"
asset "github.com/amitybell/piper-asset"
alan "github.com/amitybell/piper-voice-alan"
jenny "github.com/amitybell/piper-voice-jenny"
)
func TestPiper(t *testing.T) {
dataDir, err := os.MkdirTemp("", "ab-piper.")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dataDir)
assets := map[string]asset.Asset{
"jenny": jenny.Asset,
"alan": alan.Asset,
}
for name, asset := range assets {
tts, err := New(dataDir, asset)
if err != nil {
t.Fatal(err)
}
// Test with default options
t.Run(name+"_default", func(t *testing.T) {
wav, err := tts.Synthesize("hello world")
if err != nil {
t.Fatalf("%s: %s\n", name, err)
}
if len(wav) < 44 {
t.Fatalf("%s: Invalid wav file generated: len(%d)\n", name, len(wav))
}
})
// Test with custom speed option
t.Run(name+"_custom_speed", func(t *testing.T) {
wav, err := tts.Synthesize("hello world", WithSpeed(1.2))
if err != nil {
t.Fatalf("%s: %s\n", name, err)
}
if len(wav) < 44 {
t.Fatalf("%s: Invalid wav file generated: len(%d)\n", name, len(wav))
}
})
// Test with custom noise option
t.Run(name+"_custom_noise", func(t *testing.T) {
wav, err := tts.Synthesize("hello world", WithNoise(0.5))
if err != nil {
t.Fatalf("%s: %s\n", name, err)
}
if len(wav) < 44 {
t.Fatalf("%s: Invalid wav file generated: len(%d)\n", name, len(wav))
}
})
// Test with both custom speed and noise options
t.Run(name+"_custom_speed_and_noise", func(t *testing.T) {
wav, err := tts.Synthesize("hello world", WithSpeed(1.2), WithNoise(0.5))
if err != nil {
t.Fatalf("%s: %s\n", name, err)
}
if len(wav) < 44 {
t.Fatalf("%s: Invalid wav file generated: len(%d)\n", name, len(wav))
}
})
}
}