1. Go to this page and download the library: Download ondewo/s2t-client-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ondewo / s2t-client-php example snippets
use Ondewo\S2t\Auth\BearerTokenAuthenticator; // hand-written, from auth/
use Ondewo\S2t\Speech2TextClient; // generated, from src/
rpc\ChannelCredentials;
use Ondewo\S2t\Auth\BearerTokenAuthenticator;
use Ondewo\S2t\ListS2tPipelinesRequest;
use Ondewo\S2t\Speech2TextClient;
// The PHP namespace is protoc's UpperCamel form of the proto package:
// `package ondewo.s2t;` becomes `Ondewo\S2t`, and the service `Speech2Text` becomes
// `Speech2TextClient` (grpc_php_plugin's default class suffix). Browse src/Ondewo/S2t for
// the messages your pinned API version actually declares.
//
// BearerTokenAuthenticator is the hand-written half: it builds the `$opts` array and
// stamps `authorization: Bearer <token>` onto the metadata of every call.
$auth = new BearerTokenAuthenticator(getenv('ONDEWO_TOKEN'));
$client = new Speech2TextClient(
getenv('ONDEWO_S2T_HOST') ?: 'localhost:50055',
$auth->channelOptions(ChannelCredentials::createSsl())
);
$request = new ListS2tPipelinesRequest();
$request->setLanguages(['de']);
[$response, $status] = $client->ListS2tPipelines($request)->wait();
if ($status->code !== \Grpc\STATUS_OK) {
throw new RuntimeException("gRPC call failed ({$status->code}): {$status->details}");
}
echo $response->serializeToJsonString(), PHP_EOL;
use Ondewo\S2t\Auth\BearerTokenAuthenticator;
use Ondewo\S2t\Auth\ClientConfig;
use Ondewo\S2t\Speech2TextClient;
$config = new ClientConfig(
host: '10.0.0.5',
port: 50051,
grpcCert: file_get_contents('certs/ca.pem'),
grpcClientCert: file_get_contents('certs/client.pem'), // leave both out for server-authenticated TLS
grpcClientKey: file_get_contents('certs/client.key'),
);
$client = new Speech2TextClient($config->target(), $config->channelOptions([
'update_metadata' => new BearerTokenAuthenticator(getenv('ONDEWO_TOKEN')),
'grpc.ssl_target_name_override' => 's2t.example.internal', // only when connecting by IP
]));
bash
composer
bash
composer
json
{
"ewo/s2t-client-php": "^7.5"
}
}
bash
git clone --recurse-submodules [email protected]:ondewo/ondewo-s2t-client-php.git
cd ondewo-s2t-client-php
make setup_developer_environment_locally
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.