1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure OpenAI Text to speech で今日の天気予報を読み上げる

1
Posted at

テキスト読み上げ (プレビュー)
現在プレビュー段階にある OpenAI テキスト読み上げモデルを使って、テキストを音声に合成できます。

Azure AI 音声経由で OpenAI テキスト読み上げの音声を使うこともできます。 詳細については、Azure OpenAI Service または Azure AI 音声経由の OpenAI テキスト読み上げ音声のガイドを参照してください。

こちらを遊んでみたメモです。

材料

  • Azure OpenAI
  • Azure Logic Apps
  • SharePoint (ストレージなど *.mp3 を格納する場所)

詳細

Azure OpenAI

自分用のデプロイをひとつ用意しております。tts-hd を選びました。

image.png

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/speech?api-version=2024-12-01-preview

ここでは以下を用いています。

https://nobuk-m6ftfebf-swedencentral.cognitiveservices.azure.com/openai/deployments/noytts-hd/audio/speech?api-version=2024-05-01-preview

image.png

Azure Logic Apps

マネージド ID

先に、当該 Logic Apps のシステム割り当てマネージド ID を有効にしておきます。Azure ロールの割り当てには Cognitive Services OpenAI User を指定しておきます。

image.png

トリガー

ワークフローを作成していきます。日次実行としています。

image.png

今日の予報を取得する

場所は東京。ほか特に何もしていません。

image.png

テキストの翻訳

今日の予報の概要を翻訳元テキストとして設定します。

image.png

HTTP リクエスト

image.png

先ほど確認したエンドポイントへ POST を送ります。

本文は以下。

JSON
{
  "model": "tts-hd",
  "input": "@{body('テキストの翻訳')}",
  "voice": "alloy"
}

Rest API で以下と同様になります。

POST https://nobuk-m6ftfebf-swedencentral.cognitiveservices.azure.com/openai/deployments/noytts-hd/audio/speech?api-version=2024-05-01-preview
Content-Type: application/json
api-key: <api-key>

{
    "model": "tts-hd",
    "input": "<音声にしたいテキスト>",
    "voice": "alloy"
}

ファイルの作成

SharePoint (またはストレージなど *.mp3 を格納する場所) を用意しておきます。Response の Body をそのままコンテンツとして保存します。

image.png

例:
image.png

完成

speech.mp3

image.png
出力:
image.png

参考

OpenAI テキスト読み上げ音声とは - Azure AI services | Microsoft Learn
テキスト読み上げについてのよくあるご質問 (FAQ) - Azure AI services | Microsoft Learn

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?