質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Google Home

Google Homeは、Google社が開発したスマートスピーカーです。無線通信接続機能と音声操作の「Googleアシスタント」という機能を搭載。話しかけることで、音楽を聞いたり、写真や画像を見たり、様々なサービスを起動することができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

1回答

2461閲覧

DialogflowのAPIv2をpythonで実装したい。

退会済みユーザー

退会済みユーザー

総合スコア0

Google Home

Google Homeは、Google社が開発したスマートスピーカーです。無線通信接続機能と音声操作の「Googleアシスタント」という機能を搭載。話しかけることで、音楽を聞いたり、写真や画像を見たり、様々なサービスを起動することができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2018/08/06 08:49

編集2018/08/18 17:32

DialogflowのAPIにv2が出たということなので、ローカル環境で動作するようにv1からの切り替え作業を行っているのですが、エラーが出てしまい困っています。
どのように対処したらよいのでしょうか。
また、session_idについて、v2ではどこから取得すればいいのかがよくわかっていません。
session_idはどのように扱えばいいのでしょうか。

■環境
python3.4.5

■参考にしたサイト
https://dialogflow-python-client-v2.readthedocs.io/en/latest/
こちらのDetecting Intent (Texts)を参考にしています。

■APIのコード

local.py

1project_id = "プロジェクトのID" 2session_id = "" 3language_code = "ja" 4session_client = dialogflow.SessionsClient() 5 6session = session_client.session_path(project_id, session_id) 7 8text_input = dialogflow.types.TextInput(text=query, language_code=language_code) 9query_input = dialogflow.types.QueryInput(text=text_input) 10response = session_client.detect_intent(session=session, query_input=query_input) 11print('Query text: {}'.format(response.query_result.query_text)) 12print('Detected intent: {} (confidence: {})\n'.format(response.query_result.intent.display_name,response.query_result.intent_detection_confidence)) 13print('Fulfillment text: {}\n'.format(response.query_result.fulfillment_text))

■コード実行時のエラー

2018-08-06 17:43:45,347 _default.py 303 WARNING No project ID could be determined. Consider running `gcloud config set project` or setting the GOOGLE_CLOUD_PROJECT environment variable Traceback (most recent call last): File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\grpc_helpers.py", line 54, in error_remapped_callable return callable_(*args, **kwargs) File "C:\Anaconda3\envs\py34\lib\site-packages\grpc\_channel.py", line 514, in __call__ return _end_unary_response_blocking(state, call, False, None) File "C:\Anaconda3\envs\py34\lib\site-packages\grpc\_channel.py", line 448, in _end_unary_response_blocking raise _Rendezvous(state, None, None, deadline) grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with: status = StatusCode.PERMISSION_DENIED details = "Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry." debug_error_string = "{"created":"@1533545026.267000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1095,"grpc_message":"Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","grpc_status":7}" > The above exception was the direct cause of the following exception: Traceback (most recent call last): File "local.py", line 42, in <module> response = session_client.detect_intent(session=session, query_input=query_input) File "C:\Anaconda3\envs\py34\lib\site-packages\dialogflow_v2\gapic\sessions_client.py", line 270, in detect_intent request, retry=retry, timeout=timeout, metadata=metadata) File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__ return wrapped_func(*args, **kwargs) File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func on_error=on_error, File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\retry.py", line 177, in retry_target return target() File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout return func(*args, **kwargs) File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\grpc_helpers.py", line 56, in error_remapped_callable six.raise_from(exceptions.from_grpc_error(exc), exc) File "<string>", line 3, in raise_from google.api_core.exceptions.PermissionDenied: 403 Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

実装する必要がなくなりましたので、この質問はクローズします。

投稿2018/10/11 08:04

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問