func ExampleIvona_ListVoices() { client := ivona.New("IVONA_ACCESS_KEY", "IVONA_SECRET_KEY") r, err := client.ListVoices(ivona.Voice{}) if err != nil { log.Fatal(err) } log.Printf("%v\n", len(r.Voices)) }
func ExampleIvona_CreateSpeech() { client := ivona.New("IVONA_ACCESS_KEY", "IVONA_SECRET_KEY") options := ivona.NewSpeechOptions("Hello World") r, err := client.CreateSpeech(options) if err != nil { log.Fatal(err) } log.Printf("%v\n", len(r.Audio)) log.Printf("%v\n", r.ContentType) log.Printf("%v\n", r.RequestID) }
func TestIvona_ListVoices(t *testing.T) { client := ivona.New(ivonaAccessKey, ivonaSecretKey) r, err := client.ListVoices(ivona.Voice{}) if err != nil { t.Error(err) } voicesLength := len(r.Voices) expectedVoicesLength := 51 expectedContentType := "application/json" if voicesLength != expectedVoicesLength { t.Errorf("Voices length %v does not match", len(r.Voices)) } if r.ContentType != expectedContentType { t.Errorf("ContentType %v does not match", r.ContentType) } }
func TestIvona_CreateSpeech(t *testing.T) { client := ivona.New(ivonaAccessKey, ivonaSecretKey) options := ivona.NewSpeechOptions(testText) r, err := client.CreateSpeech(options) if err != nil { t.Error(err) } audioLength := len(r.Audio) expectedAudioLength := 6314 expectedContentType := "audio/mpeg" if r.ContentType != expectedContentType { t.Errorf("ContentType %v does not match", r.ContentType) } if audioLength != expectedAudioLength { t.Errorf("Audio length %v does not match", audioLength) } }
func initIvona(accessKey, secretKey string) { client = ivonago.New(accessKey, secretKey) }