> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sambanova.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 音声入力機能の実装

音声対応を必要とする開発者向けに、SambaNova は OpenAI の Whisper large-v3 モデルを提供しており、リアルタイムの文字起こしと翻訳を実現できます。

<Warning>
  この機能は SambaStack ユーザーのみ利用できます。Whisper-Large-v3 は SambaCloud では利用できません。
</Warning>

## Whisper-Large-v3

* **モデル**: Whisper-Large-v3
* **説明**: 最先端の自動音声認識 (ASR) および翻訳モデル。OpenAI が開発し、500 万時間を超えるラベル付き音声データで学習されています。幅広いドメインにわたる多言語およびゼロショットの音声タスクに優れています。
* **モデル ID**: `Whisper-Large-v3`
* **対応言語**: 多言語

### 主な機能

* 長時間の音声入力 (最大 25 MB) の文字起こしと翻訳。
* 音声認識および翻訳タスクにおける高い精度。
* 文字起こし (transcriptions) と翻訳 (translations) のための OpenAI 互換エンドポイントの提供。

### リクエストパラメータ

| パラメータ | 型 | 説明 | デフォルト値 | エンドポイント |
| :- | :- | :- | :- | :- |
| `model` | String | 使用するモデルの ID。 | 必須 | `transcriptions`、`translations` |
| `file` | File | FLAC、MP3、MP4、MPEG、MPGA、M4A、Ogg、WAV、または WebM 形式の音声ファイル。ファイルサイズ上限: 25MB。 | 必須 | `transcriptions`、`translations` |
| `prompt` | String | 文字起こしのスタイルや語彙に影響を与えるプロンプト。例: "Please transcribe carefully, including pauses and hesitations." | 任意 | `transcriptions`、`translations` |
| `response_format` | String | 出力形式。対応している値は `json` と `text` のみです。 | `json` | `transcriptions`、`translations` |
| `language` | String | 入力音声の言語。ISO-639-1 形式 (例: `en`) で指定すると、精度とレイテンシが向上します。 | 任意 | `transcriptions`、`translations` |
| `stream` | Boolean | ストリーミング応答を有効にします。 | `false` | `transcriptions`、`translations` |
| `stream_options` | Object | 追加のストリーミング設定 (例: `{"include_usage": true}`)。 | 任意 | `transcriptions`、`translations` |

<Note>
  Whisper-Large-v3 が対応している `response_format` の値は `json` と `text` のみです。

  * `verbose_json`、`srt`、`vtt` には現在対応していません。これらを指定した場合はプレーンテキストで返されます。
  * `timestamp_granularities` には対応しておらず、`{"error":{"message":"Unknown parameter: 'timestamp_granularities'."}}` が返されます。
</Note>

### 使用例

<CodeGroup>
  ```python Python (SambaNova) theme={}
  from sambanova import SambaNova
  import base64

  client = SambaNova(
      base_url="your-sambanova-base-url",
      api_key="your-sambanova-api-key",
  )

  audio_path="audio_path"
  with open(audio_path, "rb") as audio_file:
     bin_audio = audio_file.read()

  response = client.audio.transcriptions.create(
      model="Whisper-Large-v3",
      file=(audio_path,bin_audio),
  )
  print(str(response))
  ```

  ```python Python (OpenAI) theme={}
  from openai import OpenAI
  import base64

  client = OpenAI(
      base_url="your-sambanova-base-url",
      api_key="your-sambanova-api-key",
  )

  audio_path="audio_path"
  with open(audio_path, "rb") as audio_file:
     bin_audio = audio_file.read()

  response = client.audio.transcriptions.create(
      model="Whisper-Large-v3",
      file=(audio_path,bin_audio),
  )
  print(str(response))
  ```

  ```javascript Javascript (SambaNova) theme={}
  import SambaNova from "sambanova";

  const client = new SambaNova({
    baseURL: 'your-sambanova-base-url',
    apiKey: 'your-sambanova-api-key'
  });

  async function run() {
    const audioPath = 'audio_path';
    const binAudio = fs.createReadStream(audioPath);

    const response = await client.audio.transcriptions.create({
      model: 'Whisper-Large-v3',
      file: binAudio,
    });

    console.log('Full Response:');
    console.dir(response, { depth: null });
  }

  run().catch(console.error);
  ```
</CodeGroup>

## 翻訳

translations エンドポイントは、対応している任意の言語の音声を文字起こしし、英語で出力を返します。`language` パラメータで入力音声の言語を ISO 639-1 形式 (例: スペイン語は `"es"`) で指定すると、精度が向上し、レイテンシを低減できます。

### 使用例

<CodeGroup>
  ```python Python (SambaNova) theme={}
  from sambanova import SambaNova

  client = SambaNova(
      base_url="your-sambanova-base-url",
      api_key="your-sambanova-api-key",
  )

  audio_path = "audio_path"
  with open(audio_path, "rb") as audio_file:
      bin_audio = audio_file.read()

  response = client.audio.translations.create(
      model="Whisper-Large-v3",
      file=(audio_path, bin_audio),
      language="es",
  )
  print(str(response))
  ```

  ```python Python (OpenAI) theme={}
  from openai import OpenAI

  client = OpenAI(
      base_url="your-sambanova-base-url",
      api_key="your-sambanova-api-key",
  )

  audio_path = "audio_path"
  with open(audio_path, "rb") as audio_file:
      bin_audio = audio_file.read()

  response = client.audio.translations.create(
      model="Whisper-Large-v3",
      file=(audio_path, bin_audio),
      language="es",
  )
  print(str(response))
  ```

  ```javascript Javascript (SambaNova) theme={}
  import SambaNova from "sambanova";

  const client = new SambaNova({
    baseURL: 'your-sambanova-base-url',
    apiKey: 'your-sambanova-api-key'
  });

  async function run() {
    const audioPath = 'audio_path';
    const binAudio = fs.createReadStream(audioPath);

    const response = await client.audio.translations.create({
      model: 'Whisper-Large-v3',
      file: binAudio,
      language: 'es',
    });

    console.log('Full Response:');
    console.dir(response, { depth: null });
  }

  run().catch(console.error);
  ```
</CodeGroup>

### 応答例

```json theme={}
{
  "text": "It is the sound effect of a bell ringing, specifically a church bell."
}
```
