Exemple #1
0
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))
}
Exemple #2
0
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)
}
Exemple #3
0
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)
	}
}
Exemple #4
0
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)
	}
}
Exemple #5
0
func initIvona(accessKey, secretKey string) {
	client = ivonago.New(accessKey, secretKey)
}