Git Product home page Git Product logo

speak-unity-sample's Introduction

SpeakSDK for Unity サンプルアプリケーション

本ソースコードは株式会社NTTドコモが提供するドコモAIエージェントAPI SpeakSDKのサンプルコードです。

アプリケーションの概要

AIエージェントAPI・SpeakSDKを利用することで実現可能な音声対話アプリケーションのサンプルコードです。 SpeakSDKを利用した音声対話処理やUIの実装例としてご利用ください。

利用方法

下記のチュートリアルをご参照ください。

音声対話サンプルアプリ作成チュートリアル

動作条件

  1. 対象OS:Android, iOS, LuminOS, PC(macOS,Windows)
  2. Speak SDK(1.14.0以上)
  3. 対象Unityバージョン:2019.4.4f1

推奨開発環境

iOS向けUnityアプリをビルドおよびデプロイする際は、Xcodeが必要となります。そのため、開発環境としてMacを使用することを推奨します。

VR機器向けアプリケーションのビルド

Oculus Quest向け

Oculus向けUnityアプリをビルドする際は、Oculus Integrationをインポートする必要があります。

  1. Unityから Window > Assets Store を選択し、AssetStoreを表示します。
  2. AssetStore内を「Oculus Integration」で検索します。
  3. 検索結果からOculus Integrationを選択して「Download」ボタンを押下します。
  4. ダウンロード後、「Import」ボタンを押下しOculus Integrationをインポートします。

MagicLeap向け

MagicLeap向けUnityアプリをビルドする際は、LuminSDKに含まれるMagicLeap.unitypackageのインポート、およびアプリケーション公開用証明書の設定を行う必要があります。 詳細な設定手順は下記ユーザーズガイドをご確認ください。

Speak Unity SDK User's Guide

デバイストークンの取得

対話サービスを利用するにはデバイスIDの登録とデバイストークンの取得が必要です。 Pythonスクリプトを利用してデバイストークンの取得を行ってください。

トライアルサーバ向け手順

トライアルサーバ向けは GetTrialDeviceToken.py のスクリプトを使用します。 スクリプト中における CLIENT_SECRET はダミー値であるため、Agentcraftの設定タグから、ご自身で取得した値に書き換えて実行してください。 GetTrialDeviceToken.pyを実行すると以下の様にデバイスID・デバイストークン・リフレッシュトークンが標準出力に表示されます。

{
  "device_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
SAVE ./.trial_device_id : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
{
  "device_token": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
  "refresh_token": "oooooooo-oooo-oooo-oooo-oooooooooooo"
}
SAVE ./.trial_device_token : yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
SAVE ./.trial_refresh_token : oooooooo-oooo-oooo-oooo-oooooooooooo

商用サーバ向け手順

商用サーバ向けは GetProductionDeviceToken.py のスクリプトを使用します。 スクリプト中における client_secret はダミー値であるため、ご自身で取得した値に書き換えて実行してください。

GetProductionDeviceToken.pyを実行すると以下の様にデバイスID登録用のURLを表示して登録の完了を待機します。

$ python3 GetProductionDeviceToken.py
Success to get DeviceID :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
デバイスIDの取得に成功しました。
Please register DeviceID as your device on User Dashboard.
下記リンク(↓)を使ってブラウザ等でデバイスIDを自分のアカウントに登録して下さい。
https://doufr.aiplat.jp/device/regist?directAccess=true&deviceId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Press any key AFTER registration >>> 

ブラウザでURLにアクセスしてデバイスID登録を完了させて下さい。
登録にはdアカウントによる認証が必要です。

登録が完了したらEnterを入力して下さい。 デバイストークンとリフレッシュトークンが標準出力に表示されます。

Success to get DeviceToken : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
デバイストークンの取得に成功しました。
Success to get RefreshToken : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
リフレッシュトークンの取得に成功しました。

リフレッシュトークンはデバイストークンの更新に使用します。
スクリプトで取得したリフレッシュトークンを隠しファイルに保存しています。 デバイストークンの使用期限が切れた時は、スクリプトを再び実行して下さい。 保存したリフレッシュトークンでデバイストークンを更新します。

接続先の変更

サンプルコード中における接続先設定値はダミー値となっています。 SpeakSDKManager.cs の以下の行を、接続先に応じて変更してください。

    Speak.Instance().SetURL("wss://hostname.domain:443/path");
    Speak.Instance().SetDeviceToken("PUT_YOUR_DEVICE_TOKEN");

wss://hostname.domain:443/path を適切な接続先に置き換えます。

  • トライアルサーバ : wss://spf-v2.sebastien.ai/talk
  • 商用サーバ : wss://dospf.aiplat.jp/ciel

PUT_YOUR_DEVICE_TOKEN を取得したデバイストークンに置き換えます。

License

本サンプルコードは以下の修正BSDライセンスが適用されます。

LICENSE.txt

また本サンプルアプリケーションの動作に必要となるSpeakSDKの利用にあたっては下記ソフトウェア開発キットの利用に関する規約が適用されます。規約をご確認のうえ利用をお願いいたします。

ソフトウェア開発キットの利用に関する規約

Acknowledgments

This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
This product includes cryptographic software written by Eric Young ([email protected])

Author

NTT DOCOMO, INC.

speak-unity-sample's People

Watchers

James Cloos avatar

Forkers

haya695

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.