Skip to content

Release Notes: v0.7.0

Release Date: 2026-03-30

Highlights

  • WAV Audio Fixtures: Generate valid WAV files with proper RIFF headers for testing
  • Provider-Specific Mocks: Pre-configured mocks for ElevenLabs, Deepgram, and OpenAI TTS
  • Configurable Mock Behaviors: Functional options for latency, errors, timing, and failover testing

New Features

WAV Audio Fixtures

The providertest package now includes functions to generate valid WAV audio fixtures for testing:

import "github.com/plexusone/omnivoice-core/tts/providertest"

// Generate a 1-second WAV at 22050 Hz
fixture := providertest.GenerateWAVFixture(1000, 22050)

// Convenience functions
shortWAV := providertest.GenerateShortWAV()      // 100ms
oneSecond := providertest.GenerateOneSecondWAV() // 1 second

Generated WAV files include proper RIFF headers and can be parsed by audio tools like ffprobe.

Configurable Mock Behaviors

New MockProviderOption functional options pattern for fine-grained control:

import "github.com/plexusone/omnivoice-core/tts/providertest"

// Fixed duration audio
mock := providertest.NewMockProviderWithOptions(
    providertest.WithFixedDuration(2000), // 2 seconds
)

// Realistic timing (duration proportional to text length)
mock := providertest.NewMockProviderWithOptions(
    providertest.WithRealisticTiming(),
)

// Simulate network latency
mock := providertest.NewMockProviderWithOptions(
    providertest.WithLatency(100 * time.Millisecond),
)

// Error injection
mock := providertest.NewMockProviderWithOptions(
    providertest.WithError(providertest.ErrMockRateLimit),
)

// Fail after N successful calls (for retry/failover testing)
mock := providertest.NewMockProviderWithOptions(
    providertest.WithFailAfterN(3, providertest.ErrMockQuotaExceeded),
)

Provider-Specific Mocks

Pre-configured mocks that simulate real provider behavior:

// ElevenLabs mock with Rachel, Bella, Antoni voices
elevenLabs := providertest.NewElevenLabsMock()

// Deepgram mock with Asteria, Luna, Orion voices
deepgram := providertest.NewDeepgramMock()

// OpenAI mock with Alloy, Echo, Fable, Onyx, Nova, Shimmer voices
openai := providertest.NewOpenAIMock()

Each mock:

  • Returns the correct provider name from Name()
  • Provides realistic voice lists from ListVoices()
  • Uses WithRealisticTiming() for text-proportional audio duration
  • Passes provider conformance tests

Common Test Errors

Pre-defined errors for consistent error injection:

providertest.ErrMockRateLimit     // "mock: rate limit exceeded"
providertest.ErrMockQuotaExceeded // "mock: quota exceeded"
providertest.ErrMockNetworkError  // "mock: network error"
providertest.ErrMockInvalidVoice  // "mock: invalid voice"

Use Cases

Testing TTS Integrations

func TestMyTTSIntegration(t *testing.T) {
    mock := providertest.NewElevenLabsMock()

    result, err := mock.Synthesize(ctx, "Hello world", tts.SynthesisConfig{})
    if err != nil {
        t.Fatal(err)
    }

    // Verify WAV header
    if string(result.Audio[0:4]) != "RIFF" {
        t.Error("Expected WAV format")
    }
}

Testing Error Handling

func TestRateLimitRetry(t *testing.T) {
    mock := providertest.NewMockProviderWithOptions(
        providertest.WithError(providertest.ErrMockRateLimit),
    )

    _, err := mock.Synthesize(ctx, "test", tts.SynthesisConfig{})
    if err != providertest.ErrMockRateLimit {
        t.Errorf("Expected rate limit error, got %v", err)
    }
}

Testing Failover Logic

func TestProviderFailover(t *testing.T) {
    // Primary fails after 2 calls
    primary := providertest.NewMockProviderWithOptions(
        providertest.WithFailAfterN(2, providertest.ErrMockQuotaExceeded),
    )

    // Fallback always succeeds
    fallback := providertest.NewDeepgramMock()

    // Test your failover logic...
}

Testing Context Cancellation

func TestCancellation(t *testing.T) {
    mock := providertest.NewMockProviderWithOptions(
        providertest.WithLatency(5 * time.Second),
    )

    ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
    defer cancel()

    _, err := mock.Synthesize(ctx, "test", tts.SynthesisConfig{})
    if err == nil {
        t.Error("Expected context cancellation error")
    }
}

Installation

go get github.com/plexusone/omnivoice-core@v0.7.0

Full Changelog

See CHANGELOG.md for the complete list of changes.