@@ -45,11 +45,12 @@ See: `Speech Asynchronous Recognize`_
4545.. code-block :: python
4646
4747 >> > import time
48- >> > from google.cloud.speech.sample import Sample
48+ >> > from google.cloud import speech
4949 >> > from google.cloud.speech.encoding import Encoding
50- >> > sample = Sample(source_uri = ' gs://my-bucket/recording.flac' ,
51- ... encoding = Encoding.FLAC ,
52- ... sample_rate = 44100 )
50+ >> > client = speech.Client()
51+ >> > sample = client.sample(source_uri = ' gs://my-bucket/recording.flac' ,
52+ ... encoding = Encoding.FLAC ,
53+ ... sample_rate = 44100 )
5354 >> > operation = client.async_recognize(sample, max_alternatives = 2 )
5455 >> > retry_count = 100
5556 >> > while retry_count > 0 and not operation.complete:
@@ -75,11 +76,12 @@ Great Britian.
7576
7677.. code-block :: python
7778
78- >> > from google.cloud.speech.sample import Sample
79+ >> > from google.cloud import speech
7980 >> > from google.cloud.speech.encoding import Encoding
80- >> > sample = Sample(source_uri = ' gs://my-bucket/recording.flac' ,
81- ... encoding = Encoding.FLAC ,
82- ... sample_rate = 44100 )
81+ >> > client = speech.Client()
82+ >> > sample = client.sample(source_uri = ' gs://my-bucket/recording.flac' ,
83+ ... encoding = Encoding.FLAC ,
84+ ... sample_rate = 44100 )
8385 >> > operation = client.async_recognize(sample, max_alternatives = 2 )
8486 >> > alternatives = client.sync_recognize(
8587 ... ' FLAC' , 16000 , source_uri = ' gs://my-bucket/recording.flac' ,
@@ -99,11 +101,12 @@ Example of using the profanity filter.
99101
100102.. code-block :: python
101103
102- >> > from google.cloud.speech.sample import Sample
104+ >> > from google.cloud import speech
103105 >> > from google.cloud.speech.encoding import Encoding
104- >> > sample = Sample(source_uri = ' gs://my-bucket/recording.flac' ,
105- ... encoding = Encoding.FLAC ,
106- ... sample_rate = 44100 )
106+ >> > client = speech.Client()
107+ >> > sample = client.sample(source_uri = ' gs://my-bucket/recording.flac' ,
108+ ... encoding = Encoding.FLAC ,
109+ ... sample_rate = 44100 )
107110 >> > alternatives = client.sync_recognize(sample, max_alternatives = 1 ,
108111 ... profanity_filter = True )
109112 >> > for alternative in alternatives:
@@ -120,11 +123,12 @@ words to the vocabulary of the recognizer.
120123
121124.. code-block :: python
122125
123- >> > from google.cloud.speech.sample import Sample
126+ >> > from google.cloud import speech
124127 >> > from google.cloud.speech.encoding import Encoding
125- >> > sample = Sample(source_uri = ' gs://my-bucket/recording.flac' ,
126- ... encoding = Encoding.FLAC ,
127- ... sample_rate = 44100 )
128+ >> > client = speech.Client()
129+ >> > sample = client.sample(source_uri = ' gs://my-bucket/recording.flac' ,
130+ ... encoding = Encoding.FLAC ,
131+ ... sample_rate = 44100 )
128132 >> > hints = [' hi' , ' good afternoon' ]
129133 >> > alternatives = client.sync_recognize(sample, max_alternatives = 2 ,
130134 ... speech_context = hints)
0 commit comments