- Implemented core model components in `modules.py` including various convolutional layers and normalization techniques. - Added transformation functions in `transforms.py` for piecewise rational quadratic transformations. - Created utility functions in `utils.py` for checkpoint management, logging, and hyperparameter handling. - Introduced monotonic alignment functionality with Cython optimization in `monotonic_align`. - Developed a minimal inference server in `server.py` to handle synthesis requests. - Updated requirements to include necessary dependencies for Cython and scipy.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package ffmpeg
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"testing"
|
|
)
|
|
|
|
func TestEncodeWAV(t *testing.T) {
|
|
pcm := []float32{0, 1, -1, 2, -2} // last two exercise clamping
|
|
sampleRate := 22050
|
|
|
|
data := encodeWAV(pcm, sampleRate)
|
|
|
|
if string(data[0:4]) != "RIFF" || string(data[8:12]) != "WAVE" {
|
|
t.Fatalf("encodeWAV() missing RIFF/WAVE header: %q", data[:12])
|
|
}
|
|
if string(data[12:16]) != "fmt " || string(data[36:40]) != "data" {
|
|
t.Fatalf("encodeWAV() missing fmt/data chunk headers")
|
|
}
|
|
|
|
gotSampleRate := binary.LittleEndian.Uint32(data[24:28])
|
|
if gotSampleRate != uint32(sampleRate) {
|
|
t.Fatalf("encodeWAV() sample rate = %d, want %d", gotSampleRate, sampleRate)
|
|
}
|
|
|
|
dataSize := binary.LittleEndian.Uint32(data[40:44])
|
|
if int(dataSize) != len(pcm)*2 {
|
|
t.Fatalf("encodeWAV() data size = %d, want %d", dataSize, len(pcm)*2)
|
|
}
|
|
|
|
samples := data[44:]
|
|
want := []int16{0, 32767, -32767, 32767, -32767} // clamped to [-1, 1] before scaling
|
|
for i, w := range want {
|
|
got := int16(binary.LittleEndian.Uint16(samples[i*2 : i*2+2]))
|
|
if got != w {
|
|
t.Errorf("sample %d = %d, want %d", i, got, w)
|
|
}
|
|
}
|
|
}
|