Skip to content

Commit 822c33b

Browse files
committed
Fixed failing tests
1 parent 2da4722 commit 822c33b

5 files changed

Lines changed: 9 additions & 6 deletions

File tree

ivona_api/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
2+
from __future__ import absolute_import, unicode_literals
3+
4+
from ivona_api.ivona_api import IvonaAPI # noqa
35

46

57
__version__ = '0.1.1'

ivona_api/ivona_api.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414

1515

16-
class IvonaAPI:
16+
class IvonaAPI(object):
1717
"""
1818
Base class that for accessing Ivona web API.
1919
Currently implements 'CreateSpeech' and 'ListVoices' endpoints, without
@@ -105,7 +105,7 @@ def get_available_voices(self, filter_language=None):
105105

106106
return r.json()['Voices']
107107

108-
def text_to_speech(self, text, file, voice_name=None, language=None):
108+
def text_to_speech(self, text, path, voice_name=None, language=None):
109109
"""
110110
Saves given text synthesized audio file, via 'CreateSpeech' endpoint
111111
http://developer.ivona.com/en/speechcloud/actions.html#CreateSpeech
@@ -123,7 +123,7 @@ def text_to_speech(self, text, file, voice_name=None, language=None):
123123

124124
data = {
125125
'Input': {
126-
'Data': str(text),
126+
'Data': text,
127127
},
128128
'OutputFormat': {
129129
'Codec': self.codec.upper(),
@@ -145,6 +145,7 @@ def text_to_speech(self, text, file, voice_name=None, language=None):
145145
if 'x-amzn-ErrorType' in r.headers:
146146
raise IvonaAPIException(r.headers['x-amzn-ErrorType'])
147147

148+
file = open(path, 'wb')
148149
file.write(r.content)
149150

150151
return True
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

ivona_api/test/test_ivona_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_text_to_speech(auth_keys, voice_name, voice_language, content,
9090
)
9191

9292
with tempfile.NamedTemporaryFile() as temp_file:
93-
ivona_api.text_to_speech(content, temp_file)
93+
ivona_api.text_to_speech(content, temp_file.name)
9494

9595
assert filecmp.cmp(org_file, temp_file.name)
9696

@@ -102,6 +102,6 @@ def test_text_to_speech_custom_voice(auth_keys):
102102
with pytest.raises(ValueError):
103103
with tempfile.NamedTemporaryFile() as temp_file:
104104
ivona_api.text_to_speech(
105-
str(uuid4()), temp_file,
105+
str(uuid4()), temp_file.name,
106106
voice_name=str(uuid4()),
107107
)

0 commit comments

Comments
 (0)