Skip to content
This repository has been archived by the owner on Apr 13, 2018. It is now read-only.

Commit

Permalink
移除百度语音的cuid配置
Browse files Browse the repository at this point in the history
  • Loading branch information
wzpan committed May 20, 2017
1 parent 8bc7d02 commit a3a9219
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
3 changes: 3 additions & 0 deletions client/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ cmuclmtk==0.1.5
# Email plugin
python-dateutil==2.3

# Time plugin
semantic==1.0.3

# wxbot
PyQRCode==1.2.1
pydub==0.18.0
Expand Down
11 changes: 3 additions & 8 deletions client/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import dingdangpath
import diagnose
import vocabcompiler
from uuid import getnode as mac
from uuid import getnode as get_mac

import sys

Expand Down Expand Up @@ -200,17 +200,15 @@ class BaiduSTT(AbstractSTTEngine):
baidu_yuyin: 'AIzaSyDoHmTEToZUQrltmORWS4Ott0OHVA62tw8'
api_key: 'LMFYhLdXSSthxCNLR7uxFszQ'
secret_key: '14dbd10057xu7b256e537455698c0e4e'
cuid: 'xx-xx-xx-xx-xx-xx' # your mac address
...
"""

SLUG = "baidu-stt"

def __init__(self, api_key, secret_key, cuid):
def __init__(self, api_key, secret_key):
self._logger = logging.getLogger(__name__)
self.api_key = api_key
self.secret_key = secret_key
self.cuid = cuid

@classmethod
def get_config(cls):
Expand All @@ -228,9 +226,6 @@ def get_config(cls):
if 'secret_key' in profile['baidu_yuyin']:
config['secret_key'] = \
profile['baidu_yuyin']['secret_key']
if 'cuid' in profile['baidu_yuyin']:
config['cuid'] = \
profile['baidu_yuyin']['cuid']
return config

def get_token(self):
Expand Down Expand Up @@ -267,7 +262,7 @@ def transcribe(self, fp):
"len": len(audio),
"rate": frame_rate,
"speech": base_data,
"cuid": self.cuid,
"cuid": str(get_mac())[:32],
"channel": 1}
data = json.dumps(data)
r = requests.post('http://vop.baidu.com/server_api',
Expand Down
10 changes: 3 additions & 7 deletions client/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import requests
import threading
from abc import ABCMeta, abstractmethod
from uuid import getnode as get_mac

import argparse
import yaml
Expand Down Expand Up @@ -439,17 +440,15 @@ class BaiduTTS(AbstractMp3TTSEngine):
baidu_yuyin: 'AIzaSyDoHmTEToZUQrltmORWS4Ott0OHVA62tw8'
api_key: 'LMFYhLdXSSthxCNLR7uxFszQ'
secret_key: '14dbd10057xu7b256e537455698c0e4e'
cuid: 'xx-xx-xx-xx-xx-xx' # your mac address
...
"""

SLUG = "baidu-tts"

def __init__(self, api_key, secret_key, cuid, per=0):
def __init__(self, api_key, secret_key, per=0):
self._logger = logging.getLogger(__name__)
self.api_key = api_key
self.secret_key = secret_key
self.cuid = cuid
self.per = per

@classmethod
Expand All @@ -468,9 +467,6 @@ def get_config(cls):
if 'secret_key' in profile['baidu_yuyin']:
config['secret_key'] = \
profile['baidu_yuyin']['secret_key']
if 'cuid' in profile['baidu_yuyin']:
config['cuid'] = \
profile['baidu_yuyin']['cuid']
if 'per' in profile['baidu_yuyin']:
config['per'] = \
profile['baidu_yuyin']['per']
Expand Down Expand Up @@ -510,7 +506,7 @@ def get_speech(self, phrase):
'lan': 'zh',
'tok': self.get_token(),
'ctp': 1,
'cuid': self.cuid,
'cuid': str(get_mac())[:32],
'per': self.per
}
r = requests.post('http://tsn.baidu.com/text2audio',
Expand Down

0 comments on commit a3a9219

Please sign in to comment.