Skip to content

Latest commit

 

History

History
167 lines (118 loc) · 5.83 KB

File metadata and controls

167 lines (118 loc) · 5.83 KB

転写データ準備

転写データ準備スクリプトは、YouTubeの動画の文字起こしをダウンロードし、Semantic Search with OpenAI Embeddings and Functionsのサンプルで使用できるように準備します。

転写データ準備スクリプトは、最新リリースのWindows 11、macOS Ventura、Ubuntu 22.04(以降)でテストされています。

必要なAzure OpenAI Serviceリソースの作成

Important

OpenAIとの互換性を確保するために、Azure CLIを最新バージョンに更新することをお勧めします 詳細はドキュメントをご覧ください

  1. リソースグループを作成します

Note

この手順では、East USにある「semantic-video-search」という名前のリソースグループを使用しています。 リソースグループの名前は変更可能ですが、リソースの場所を変更する場合は、 モデルの利用可能性テーブルを確認してください。

az group create --name semantic-video-search --location eastus
  1. Azure OpenAI Serviceリソースを作成します。
az cognitiveservices account create --name semantic-video-openai --resource-group semantic-video-search \
    --location eastus --kind OpenAI --sku s0
  1. このアプリケーションで使用するために、エンドポイントとキーを取得します。
az cognitiveservices account show --name semantic-video-openai \
   --resource-group  semantic-video-search | jq -r .properties.endpoint
az cognitiveservices account keys list --name semantic-video-openai \
   --resource-group semantic-video-search | jq -r .key1
  1. 以下のモデルをデプロイします:
    • text-embedding-ada-002 バージョン 2 以上、名前は text-embedding-ada-002
    • gpt-35-turbo バージョン 0613 以上、名前は gpt-35-turbo
az cognitiveservices account deployment create \
    --name semantic-video-openai \
    --resource-group  semantic-video-search \
    --deployment-name text-embedding-ada-002 \
    --model-name text-embedding-ada-002 \
    --model-version "2"  \
    --model-format OpenAI \
    --scale-settings-scale-type "Standard"
az cognitiveservices account deployment create \
    --name semantic-video-openai \
    --resource-group  semantic-video-search \
    --deployment-name gpt-35-turbo \
    --model-name gpt-35-turbo \
    --model-version "0613"  \
    --model-format OpenAI \
    --sku-capacity 100 \
    --sku-name "Standard"

必要なソフトウェア

環境変数

YouTubeの転写データ準備スクリプトを実行するには、以下の環境変数が必要です。

Windowsの場合

ユーザー環境変数に追加することを推奨します。
Windowsスタート > システム環境変数の編集 > 環境変数 > [USER]のユーザー環境変数 > 新規

AZURE_OPENAI_API_KEY  \<your Azure OpenAI Service API key>
AZURE_OPENAI_ENDPOINT \<your Azure OpenAI Service endpoint>
AZURE_OPENAI_MODEL_DEPLOYMENT_NAME \<your Azure OpenAI Service model deployment name>
GOOGLE_DEVELOPER_API_KEY = \<your Google developer API key>

LinuxおよびmacOSの場合

以下のexport文を~/.bashrcまたは~/.zshrcファイルに追加することを推奨します。

export AZURE_OPENAI_API_KEY=<your Azure OpenAI Service API key>
export AZURE_OPENAI_ENDPOINT=<your Azure OpenAI Service endpoint>
export AZURE_OPENAI_MODEL_DEPLOYMENT_NAME=<your Azure OpenAI Service model deployment name>
export GOOGLE_DEVELOPER_API_KEY=<your Google developer API key>

必要なPythonライブラリのインストール

  1. まだインストールしていない場合は、gitクライアントをインストールします。

  2. ターミナルウィンドウから、サンプルを任意のリポジトリフォルダにクローンします。

    git clone https://github.com/gloveboxes/semanic-search-openai-embeddings-functions.git
  3. data_prepフォルダに移動します。

    cd semanic-search-openai-embeddings-functions/src/data_prep
  4. Pythonの仮想環境を作成します。

    Windowsの場合:

    python -m venv .venv

    macOSおよびLinuxの場合:

    python3 -m venv .venv
  5. Pythonの仮想環境を有効化します。

    Windowsの場合:

    .venv\Scripts\activate

    macOSおよびLinuxの場合:

    source .venv/bin/activate
  6. 必要なライブラリをインストールします。

    Windowsの場合:

    pip install -r requirements.txt

    macOSおよびLinuxの場合:

    pip3 install -r requirements.txt

YouTube転写データ準備スクリプトの実行

Windowsの場合

.\transcripts_prepare.ps1

macOSおよびLinuxの場合

./transcripts_prepare.sh

免責事項
本書類はAI翻訳サービス「Co-op Translator」を使用して翻訳されました。正確性を期しておりますが、自動翻訳には誤りや不正確な部分が含まれる可能性があります。原文の言語によるオリジナル文書が正式な情報源とみなされるべきです。重要な情報については、専門の人間による翻訳を推奨します。本翻訳の利用により生じたいかなる誤解や誤訳についても、当方は一切の責任を負いかねます。