Skip to content

Commit a6dfd9a

Browse files
authored
revert: undo removal of vision and speech veneer (googleapis#2824)
* revert: undo removal of vision and speech veneer * revert core changes
1 parent 9f3ead8 commit a6dfd9a

83 files changed

Lines changed: 10493 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Core/src/ServiceBuilder.php‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
use Google\Cloud\Logging\LoggingClient;
2828
use Google\Cloud\PubSub\PubSubClient;
2929
use Google\Cloud\Spanner\SpannerClient;
30+
use Google\Cloud\Speech\SpeechClient;
3031
use Google\Cloud\Storage\StorageClient;
3132
use Google\Cloud\Trace\TraceClient;
3233
use Google\Cloud\Translate\TranslateClient;
34+
use Google\Cloud\Vision\VisionClient;
3335
use Psr\Cache\CacheItemPoolInterface;
3436

3537
/**
@@ -266,6 +268,35 @@ public function spanner(array $config = [])
266268
return $this->createClient(SpannerClient::class, 'spanner', $config);
267269
}
268270

271+
/**
272+
* Google Cloud Speech enables easy integration of Google speech recognition
273+
* technologies into developer applications. Send audio and receive a text
274+
* transcription from the Cloud Speech API service. Find more information at
275+
* the [Google Cloud Speech API docs](https://cloud.google.com/speech/docs/).
276+
*
277+
* Example:
278+
* ```
279+
* $speech = $cloud->speech([
280+
* 'languageCode' => 'en-US'
281+
* ]);
282+
* ```
283+
*
284+
* @param array $config [optional] {
285+
* Configuration options. See
286+
* {@see Google\Cloud\Core\ServiceBuilder::__construct()} for the other available options.
287+
*
288+
* @type string $languageCode The language of the content to
289+
* be recognized. Only BCP-47 (e.g., `"en-US"`, `"es-ES"`)
290+
* language codes are accepted. See
291+
* [Language Support](https://cloud.google.com/speech/docs/languages)
292+
* for a list of the currently supported language codes.
293+
* @return SpeechClient
294+
*/
295+
public function speech(array $config = [])
296+
{
297+
return $this->createClient(SpeechClient::class, 'speech', $config);
298+
}
299+
269300
/**
270301
* Google Cloud Storage allows you to store and retrieve data on Google's
271302
* infrastructure. Find more information at the
@@ -305,6 +336,26 @@ public function trace(array $config = [])
305336
return $this->createClient(TraceClient::class, 'trace', $config);
306337
}
307338

339+
/**
340+
* Google Cloud Vision allows you to understand the content of an image,
341+
* classify images into categories, detect text, objects, faces and more.
342+
* Find more information at the
343+
* [Google Cloud Vision docs](https://cloud.google.com/vision/docs/).
344+
*
345+
* Example:
346+
* ```
347+
* $vision = $cloud->vision();
348+
* ```
349+
*
350+
* @param array $config [optional] Configuration options. See
351+
* {@see Google\Cloud\Core\ServiceBuilder::__construct()} for the available options.
352+
* @return VisionClient
353+
*/
354+
public function vision(array $config = [])
355+
{
356+
return $this->createClient(VisionClient::class, 'vision', $config);
357+
}
358+
308359
/**
309360
* Google Cloud Translation provides the ability to dynamically translate
310361
* text between thousands of language pairs and lets websites and programs

‎Core/tests/Snippet/ServiceBuilderTest.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
use Google\Cloud\Logging\LoggingClient;
2727
use Google\Cloud\PubSub\PubSubClient;
2828
use Google\Cloud\Spanner\SpannerClient;
29+
use Google\Cloud\Speech\SpeechClient;
2930
use Google\Cloud\Storage\StorageClient;
3031
use Google\Cloud\Trace\TraceClient;
3132
use Google\Cloud\Translate\TranslateClient;
33+
use Google\Cloud\Vision\VisionClient;
3234

3335
/**
3436
* @group root
@@ -58,8 +60,10 @@ public function serviceBuilderMethods()
5860
['language', LanguageClient::class, 'language'],
5961
['pubsub', PubSubClient::class, 'pubsub'],
6062
['spanner', SpannerClient::class, 'spanner', true],
63+
['speech', SpeechClient::class, 'speech'],
6164
['storage', StorageClient::class, 'storage'],
6265
['trace', TraceClient::class, 'trace'],
66+
['vision', VisionClient::class, 'vision'],
6367
['translate', TranslateClient::class, 'translate']
6468
];
6569
}

‎Core/tests/Unit/ServiceBuilderTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
use Google\Cloud\Logging\LoggingClient;
2727
use Google\Cloud\PubSub\PubSubClient;
2828
use Google\Cloud\Spanner\SpannerClient;
29+
use Google\Cloud\Speech\SpeechClient;
2930
use Google\Cloud\Storage\StorageClient;
3031
use Google\Cloud\Core\Tests\Unit\Fixtures;
3132
use Google\Cloud\Translate\TranslateClient;
33+
use Google\Cloud\Vision\VisionClient;
3234
use GuzzleHttp\Psr7\Response;
3335
use PHPUnit\Framework\TestCase;
3436
use Psr\Http\Message\RequestInterface;
@@ -182,12 +184,19 @@ public function serviceProvider()
182184
SpannerClient::class,
183185
[],
184186
[$this, 'checkAndSkipGrpcTests']
187+
], [
188+
'speech',
189+
SpeechClient::class,
190+
['languageCode' => 'en-US']
185191
], [
186192
'storage',
187193
StorageClient::class
188194
], [
189195
'translate',
190196
TranslateClient::class
197+
], [
198+
'vision',
199+
VisionClient::class
191200
]
192201
];
193202
}

‎Core/tests/Unit/ServicesNotFoundTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ public function serviceBuilderMethods()
8989
['language'],
9090
['pubsub'],
9191
['spanner'],
92+
['speech'],
9293
['storage'],
9394
['trace'],
95+
['vision'],
9496
['translate']
9597
];
9698
}

‎Speech/composer.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"license": "Apache-2.0",
55
"minimum-stability": "stable",
66
"require": {
7-
"google/gax": "^1.3"
7+
"google/cloud-core": "^1.35",
8+
"google/gax": "^1.1"
89
},
910
"require-dev": {
1011
"phpunit/phpunit": "^4.8|^5.0",
@@ -22,7 +23,7 @@
2223
"id": "cloud-speech",
2324
"target": "googleapis/google-cloud-php-speech.git",
2425
"path": "Speech",
25-
"entry": null
26+
"entry": "src/SpeechClient.php"
2627
}
2728
},
2829
"autoload": {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Google Inc. All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace Google\Cloud\Speech\Connection;
19+
20+
/**
21+
* Represents a connection to
22+
* [Google Cloud Speech](https://cloud.google.com/speech/).
23+
*
24+
* @deprecated This class is no longer supported and will be removed in a future
25+
* release.
26+
*/
27+
interface ConnectionInterface
28+
{
29+
/**
30+
* @param array $args
31+
* @return array
32+
*/
33+
public function recognize(array $args = []);
34+
35+
/**
36+
* @param array $args
37+
* @return array
38+
*/
39+
public function longRunningRecognize(array $args = []);
40+
41+
/**
42+
* @param array $args
43+
* @return array
44+
*/
45+
public function getOperation(array $args = []);
46+
}

‎Speech/src/Connection/Rest.php‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Google Inc. All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace Google\Cloud\Speech\Connection;
19+
20+
use Google\Cloud\Core\RequestBuilder;
21+
use Google\Cloud\Core\RequestWrapper;
22+
use Google\Cloud\Core\RestTrait;
23+
use Google\Cloud\Core\UriTrait;
24+
use Google\Cloud\Speech\SpeechClient;
25+
26+
/**
27+
* Implementation of the
28+
* [Google Cloud Speech JSON API](https://cloud.google.com/speech/reference/rest/).
29+
*
30+
* @deprecated This class is no longer supported and will be removed in a future
31+
* release.
32+
*/
33+
class Rest implements ConnectionInterface
34+
{
35+
use RestTrait;
36+
use UriTrait;
37+
38+
const BASE_URI = 'https://speech.googleapis.com/';
39+
40+
/**
41+
* @param array $config
42+
*/
43+
public function __construct(array $config = [])
44+
{
45+
$config += [
46+
'serviceDefinitionPath' => __DIR__ . '/ServiceDefinition/speech-v1.json',
47+
'componentVersion' => SpeechClient::VERSION
48+
];
49+
50+
$this->setRequestWrapper(new RequestWrapper($config));
51+
$this->setRequestBuilder(new RequestBuilder(
52+
$config['serviceDefinitionPath'],
53+
$this->getApiEndpoint(self::BASE_URI, $config)
54+
));
55+
56+
$class = get_class($this);
57+
$err = "The class {$class} is no longer supported";
58+
@trigger_error($err, E_USER_DEPRECATED);
59+
}
60+
61+
/**
62+
* @param array $args
63+
* @return array
64+
*/
65+
public function recognize(array $args = [])
66+
{
67+
return $this->send('speech', 'recognize', $args);
68+
}
69+
70+
/**
71+
* @param array $args
72+
* @return array
73+
*/
74+
public function longRunningRecognize(array $args = [])
75+
{
76+
return $this->send('speech', 'longrunningrecognize', $args);
77+
}
78+
79+
/**
80+
* @param array $args
81+
* @return array
82+
*/
83+
public function getOperation(array $args = [])
84+
{
85+
return $this->send('operations', 'get', $args);
86+
}
87+
}

0 commit comments

Comments
 (0)