123456789101112131415161718192021222324252627282930 |
- # -*- coding: utf-8 -*-
- """
- 阿里的语音识别API
- """
- from __future__ import division
- from ..__load__ import *
- from .base import Base
- class Ali(Base):
- def __init__(self):
- super(self.__class__, self).__init__(True)
- def setting(self, appKey, token, voice='vecan', **args):
- self.appKey = appKey
- self.token = token
- def asr(self, fp):
- result = self.sdk.asr(self.appKey, self.token, fp)
- if result is not None:
- return self.arrLog(1, result)
- else:
- return self.arrLog(2, '')
- def tts(self, phrase):
- tmpfile = self.sdk.tts(self.appKey, self.token, self.voice, phrase)
- if tmpfile is not None:
- return self.ttsLog(1, tmpfile)
- else:
- return self.ttsLog(2, '')
|