首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP - Google Speech API:找不到'Google\Cloud\Speech\SpeechClient‘类

PHP - Google Speech API:找不到'Google\Cloud\Speech\SpeechClient‘类
EN

Stack Overflow用户
提问于 2017-05-31 22:22:35
回答 0查看 1.4K关注 0票数 1

我希望有人能帮我弄清楚如何运行google的speech to text api。

https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/speech/api

我尝试运行的特定代码是:src/function/transcribe_sync.php

在末尾添加一行以调用该函数:

代码语言:javascript
复制
transcribe_sync("mono.flac", 'en-US');

它找不到依赖项。我一直在玩composer,但一直没能弄明白。

下面是错误:

代码语言:javascript
复制
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文件:

代码语言:javascript
复制
{
    "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)似乎真的很难理解。

我是不是走错路了?谢谢你的帮助!

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44287349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档