Skip to content

Commit 9e6f19b

Browse files
committed
Merge branch 'iam' of github.com:watson-developer-cloud/python-sdk into iam
2 parents 534c234 + 10aa0a4 commit 9e6f19b

4 files changed

Lines changed: 51 additions & 9 deletions

File tree

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# lint Python modules using external checkers.
22
[MASTER]
33
ignore=SVN
4-
disable=R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011,F0401,E0611,E1004,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801,C0301,C0411,R0204,W0622,inconsistent-return-statements
4+
disable=R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011,F0401,E0611,E1004,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801,C0301,C0411,R0204,W0622,E1121,inconsistent-return-statements

examples/speech_to_text_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ def on_data(self, data):
5656
mycallback = MyRecognizeCallback()
5757
with open(join(dirname(__file__), '../resources/speech.wav'),
5858
'rb') as audio_file:
59-
speech_to_text.recognize_with_websocket(
60-
audio=audio_file, recognize_callback=mycallback)
59+
speech_to_text.recognize_using_websocket(audio=audio_file, content_type="audio/l16; rate=44100",
60+
recognize_callback=mycallback)

watson_developer_cloud/speech_to_text_v1_adapter.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from watson_developer_cloud.websocket import RecognizeCallback, RecognizeListener
22
from .speech_to_text_v1 import SpeechToTextV1
33
from .watson_service import _remove_null_values
4+
from .utils import deprecated
45
import base64
56
try:
67
from urllib.parse import urlencode
@@ -10,6 +11,7 @@
1011
BEARER = 'Bearer'
1112

1213
class SpeechToTextV1Adapter(SpeechToTextV1):
14+
@deprecated('Use recognize_using_websocket() instead')
1315
def recognize_with_websocket(self,
1416
audio=None,
1517
content_type='audio/l16; rate=44100',
@@ -31,6 +33,48 @@ def recognize_with_websocket(self,
3133
smart_formatting=False,
3234
speaker_labels=None,
3335
**kwargs):
36+
return self.recognize_using_websocket(audio,
37+
content_type,
38+
recognize_callback,
39+
model,
40+
customization_id,
41+
acoustic_customization_id,
42+
customization_weight,
43+
version,
44+
inactivity_timeout,
45+
interim_results,
46+
keywords,
47+
keywords_threshold,
48+
max_alternatives,
49+
word_alternatives_threshold,
50+
word_confidence,
51+
timestamps,
52+
profanity_filter,
53+
smart_formatting,
54+
speaker_labels,
55+
**kwargs)
56+
57+
def recognize_using_websocket(self,
58+
audio,
59+
content_type,
60+
recognize_callback,
61+
model=None,
62+
customization_id=None,
63+
acoustic_customization_id=None,
64+
customization_weight=None,
65+
version=None,
66+
inactivity_timeout=None,
67+
interim_results=True,
68+
keywords=None,
69+
keywords_threshold=None,
70+
max_alternatives=1,
71+
word_alternatives_threshold=None,
72+
word_confidence=False,
73+
timestamps=False,
74+
profanity_filter=None,
75+
smart_formatting=False,
76+
speaker_labels=None,
77+
**kwargs):
3478
"""
3579
Sends audio for speech recognition using web sockets.
3680
@@ -125,9 +169,11 @@ def recognize_with_websocket(self,
125169
:rtype: dict
126170
"""
127171
if audio is None:
128-
raise ValueError('Audio must be provided')
172+
raise ValueError('audio must be provided')
173+
if content_type is None:
174+
raise ValueError('content_type must be provided')
129175
if recognize_callback is None:
130-
raise ValueError('Recognize callback must be provided')
176+
raise ValueError('recognize_callback must be provided')
131177
if not isinstance(recognize_callback, RecognizeCallback):
132178
raise Exception(
133179
'Callback is not a derived class of RecognizeCallback')

watson_developer_cloud/watson_service.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ def __str__(self):
202202
class WatsonService(object):
203203
def __init__(self, vcap_services_name, url, username=None, password=None,
204204
use_vcap_services=True, api_key=None,
205-
x_watson_learning_opt_out=False,
206205
iam_api_key=None, iam_access_token=None, iam_url=None):
207206
"""
208207
Loads credentials from the VCAP_SERVICES environment variable if
@@ -232,9 +231,6 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
232231
user_agent_string += ' ' + platform.python_version() # Python version
233232
self.user_agent_header = {'user-agent': user_agent_string}
234233

235-
if x_watson_learning_opt_out:
236-
self.default_headers = {'x-watson-learning-opt-out': 'true'}
237-
238234
if api_key is not None:
239235
self.set_api_key(api_key)
240236
elif username is not None and password is not None:

0 commit comments

Comments
 (0)