【发布时间】:2017-11-01 09:51:28
【问题描述】:
我希望有人可以帮助我弄清楚如何让 google 的语音转文本 api 运行。
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/speech/api
我要运行的具体代码是:src/functions/transcribe_sync.php
在末尾添加一行来调用函数:
transcribe_sync("mono.flac", 'en-US');
它找不到依赖项。我一直在和作曲家一起玩,但无法弄清楚。
这是错误:
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.php)似乎真的很神秘。
我是不是走错了路?感谢您的帮助!
【问题讨论】:
标签: php composer-php google-cloud-platform