2016-10-08 12 views
2

私はcurlでIBM Bluemix上のspeech-to-text APIにアクセスできません!私は、curlでセッションレスのリクエストのためのドキュメントからその例を試してみましたが、うまくいきませんでした。無効なユーザーID /パスワードメッセージがあります。ここでIBMのspeech-to-text APIにカールを付けてアクセスするにはどうすればよいですか?

は、私が得たエラーです:

"{ "コード":401、 "エラー": "認証されていません"、 "説明": " 2016-10-08T15:22:37- 04:00、エラー アクセス時にエラーERCDPLTFRM-DNLKUPERRが発生しました https://158.85.132.94:443/speech-to-text/api/v1/recognize?timestamps=true&word_alternatives_threshold=0.9&continuous=true,無効なユーザーIDまたはパスワード。あなたの資格情報 がアクセスしようとしているエンドポイントと一致していることを確認してください。一般的なエラーがGA リリースまたはその逆の「}」

に対する実験やベータ版のリリースからの資格情報を使用する をしようとしている誰も私にspeech-するためのAPIセッションレス要求を取得する方法の実施例を示すことができますcurlでテキストAPIに変換する方法

+0

ここで私はどのようにapiをリクエストしようとしますか?[リンク] http://pastebin.com/qnpygYwv – Lem

答えて

3

セッションレスコールのマニュアルは、hereです。

Watson Speech-to-Textサービスのインスタンスを作成し、そのサービスの資格情報(BluemixのユーザーIDとパスワードではない)を使用していることを確認してください。

あなたはBluemix UIでサービスを作成し、認証情報を取得するか、コマンドラインを介して、それを作成することができますすることができます

$ cf create-service speech_to_text standard my_service 

そして、あなたはサービス証明書を作成し、それを得ることができます。

$ cf create-service-key my_service credentials-1 

$ cf service-key my_service credentials-1 
Getting key credentials-1 for service instance my_service as [email protected] 

{ 
"password": "FJXUG6????", 
"url": "https://stream.watsonplatform.net/speech-to-text/api", 
"username": "147e438e-f633-4e40-8351-aaaaaaaaaa" 
} 

これでカールスクリプトで上記のユーザー名とパスワードを使用できます。下記のcurlコマンドと結果を参照してください。セキュリティのためにユーザー名、パスワード、およびその他のフィールドをマスクしました:

$ curl -X POST -v -u '80062070-1f88-4943-9a2a-aaaaaaa':'hwtTg???????' \ 
> --header 'Content-Type: audio/flac' \ 
> --data-binary @audio-file1.flac \ 
> 'https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?timestamps=true&continuous=true' 
* Trying 158.85.132.94... 
* Connected to stream.watsonplatform.net (158.85.132.94) port 443 (#0) 
* TLS 1.2 connection using TLS_RSA_WITH_AES_256_GCM_SHA384 
* Server certificate: *.watsonplatform.net 
* Server certificate: GeoTrust SSL CA - G3 
* Server certificate: GeoTrust Global CA 
* Server auth using Basic with user '80062070-1f88-4943-9a2a-aaaaaaa' 
> POST /speech-to-text/api/v1/recognize?timestamps=true&continuous=true HTTP/1.1 
> Host: stream.watsonplatform.net 
> Authorization: Basic ODAwNjIwNzAtMWY4OC00OTQzLTlhMmEtYzE0OWVmOTJkM2IyOmh3dXXXXXX== 
> User-Agent: curl/7.43.0 
> Accept: */* 
> Content-Type: audio/flac 
> Content-Length: 48363 
> Expect: 100-continue 
> 
< HTTP/1.1 100 Continue 
< X-Note: Gateway Ack 
* We are completely uploaded and fine 
< HTTP/1.1 200 OK 
< X-Backside-Transport: OK OK 
< Connection: Keep-Alive 
< Transfer-Encoding: chunked 
< Session-Name: LBBROMXYTJZKKEGE-en-US_BroadbandModel 
< X-Content-Type-Options: nosniff 
< Content-Disposition: inline; filename="result.json" 
< X-XSS-Protection: 1 
< Date: Sat, 08 Oct 2016 22:45:02 GMT 
< Via: 1.1 c6a59f5, 1.1 022614b, HTTP/1.1 d941b9b 
< Content-Type: application/json 
< Server: - 
< Set-Cookie: Watson-REMOVED; path=/speech-to-text/api; secure; HttpOnly 
< X-Client-IP: 71.70.244.18 
< X-Global-Transaction-ID: 775715492 
< X-DP-Watson-Tran-ID: stream-dp02-775715492 
< 
{ 
    "results": [ 
     { 
     "alternatives": [ 
      { 
       "timestamps": [ 
        [ 
        "the", 
        0.03, 
        0.09 
        ], 
        [ 
        "latest", 
        0.09, 
        0.6 
        ], 
        [ 
        "weather", 
        0.6, 
        0.85 
        ], 
        [ 
        "report", 
        0.85, 
        1.52 
        ] 
       ], 
       "confidence": 0.98, 
       "transcript": "the latest weather report " 
      } 
     ], 
     "final": true 
     } 
    ], 
    "result_index": 0 
* Connection #0 to host stream.watsonplatform.net left intact 
+1

他のユーザーのメモ - 正しい順序でパスと名前を設定してください。長さとパスワードは名前フィールドの上にあります。 – Lem

+0

@Alex da Silva cfはcloudfoundryの略です。https:// docs.cloudfoundry.org/cf-cli/install-go-cli.html#pkg-linux' –

2

私は同じ問題を抱えています。多くの試行の後、URLが間違っていることがわかりました。

{
"URL": "https://stream-fra.watsonplatform.net/text-to-speech/api"、
"ユーザー名":サービス資格情報を覚えておいてください「xxxxx- XXXXX-XXXXX-XXXXX」、
"パスワード": "

その後YYYYYYY"
}が、あなたはその情報で提供されたURLを使用する必要があります。以下は、私のために良いのリクエストです:

E:/Curl/curl.exe -X GET -u "XXXXX-XXXXX-XXXXX-XXXXX": "YYYYYYYを" hello_world.wav --output「https://でストリーム-fra.watsonplatform.net/text-to-speech/api/v1/synthesize?accept=audio/wav&text=Hello%20world&voice=en-US_AllisonVoice "
1

私の問題は、私の身元を括弧で囲んだことでした。チュートリアルは言う:

curl -X POST -u {username}:{password} 

ので、私は自分のユーザー名とパスワードを入れますが、私は中括弧を残しました。中括弧なしでもっとうまく動作します!

関連する問題