Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daanzu committed Jun 17, 2019
1 parent 49f8a26 commit b2dadea
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kaldi_active_grammar/cloud.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import wave

try:
# google-cloud-speech==0.36.3
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
gcloud_imported = True
except ImportError:
gcloud_imported = False

from . import _log

_log = _log.getChild('cloud')

class GCloud(object):

@staticmethod
def transcribe_data_sync(speech_data, model='default'):
# model in ['video', 'phone_call', 'command_and_search', 'default']

if not gcloud_imported:
_log.error("cloud_dictation failed because cannot find google.cloud package!")
return None
client = speech.SpeechClient()

audio = types.RecognitionAudio(content=speech_data)
Expand All @@ -35,6 +44,10 @@ def transcribe_data_sync(speech_data, model='default'):
@staticmethod
def transcribe_data_streaming(speech_data, model=None):
# model in ['video', 'phone_call', 'command_and_search', 'default']

if not gcloud_imported:
_log.error("cloud_dictation failed because cannot find google.cloud package!")
return None
client = speech.SpeechClient()

# In practice, stream should be a generator yielding chunks of audio data.
Expand Down

0 comments on commit b2dadea

Please sign in to comment.