我希望有人能帮我弄清楚如何运行google的speech to text api。
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/speech/api
我尝试运行的特定代码是:src/function/transcribe_sync.php
在末尾添加一行以调用该函数:
transcribe_sync("mono.flac", 'en-US');它找不到依赖项。我一直在玩composer,但一直没能弄明白。
下面是错误:
php transcribe_sync.php
PHP Fatal error: Uncaught Error: Class 'Google\Cloud\Speech\SpeechClient' not found in /home/bhaag/Documents/php-docs-samples-master/speech/api/src/functions/transcribe_sync.php:45
Stack trace:
#0 /home/bhaag/Documents/php-docs-samples-master/speech/api/src/functions/transcribe_sync.php(55): Google\Cloud\Samples\Speech\transcribe_sync('mono.flac', 'en-US')
#1 {main}
thrown in /home/bhaag/Documents/php-docs-samples-master/speech/api/src/functions/transcribe_sync.php on line 45下面是我的composer.json文件:
{
"require": {
"google/cloud-speech": "^0.2",
"google/cloud-storage": "^1.0",
"google/gax": "^0.8.1",
"google/proto-client-php": "^0.10.0",
"symfony/console": "^3.0",
"php-ffmpeg/php-ffmpeg": "^0.9.3"
},
"autoload": {
"psr-4": {
"Google\\Cloud\\Samples\\Speech\\": "src/"
},
"files": [
"src/functions/streaming_recognize.php",
"src/functions/transcribe_async.php",
"src/functions/transcribe_async_gcs.php",
"src/functions/transcribe_sync.php",
"src/functions/transcribe_sync_gcs.php"
]
},
"require-dev": {
"phpunit/phpunit": "~4"
}
}我已经能够运行完整的speech示例,所以我知道我已经正确设置了所有凭据,但是使用完整示例(主目录中的speech.php)似乎真的很难理解。
我是不是走错路了?谢谢你的帮助!
https://stackoverflow.com/questions/44287349
复制相似问题