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

# Generate Voice Preview

> Generate a voice preview using a voice clone to test quality before use

Generate a preview audio sample using one of your voice clones. This allows you to test voice quality and settings before using the voice clone in LinkedIn messages or other applications.

<Note>Requires the `voice:preview` permission.</Note>

## Request

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key that has `voice:preview` permission (e.g.,
  "Bearer bna-your-api-key")
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

### Body Parameters

<ParamField body="voiceId" type="string" required>
  The ID of the voice clone to use for preview generation
</ParamField>

<ParamField body="text" type="string" required>
  Text to synthesize into speech (1-500 characters)
</ParamField>

## Examples

### Basic Voice Preview

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.buena.ai/api/v2/voice-clones/preview" \
    -H "Authorization: Bearer bna-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "voiceId": "pNInz6obpgDQGcFmaJgB",
      "text": "Hello! This is a test of my voice clone. How does it sound?"
    }' \
    --output preview.mp3
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.buena.ai/api/v2/voice-clones/preview",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer bna-your-api-key",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        voiceId: "pNInz6obpgDQGcFmaJgB",
        text: "Hello! This is a test of my voice clone. How does it sound?",
      }),
    }
  );

  // Response is audio binary data
  const audioBlob = await response.blob();
  const audioUrl = URL.createObjectURL(audioBlob);
  const audio = new Audio(audioUrl);
  audio.play();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.buena.ai/api/v2/voice-clones/preview',
      headers={
          'Authorization': 'Bearer bna-your-api-key',
          'Content-Type': 'application/json'
      },
      json={
          'voiceId': 'pNInz6obpgDQGcFmaJgB',
          'text': 'Hello! This is a test of my voice clone. How does it sound?'
      }
  )

  # Save audio file
  with open('preview.mp3', 'wb') as f:
      f.write(response.content)
  print("Preview audio saved as preview.mp3")
  ```
</CodeGroup>

### Advanced Preview with Custom Settings

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.buena.ai/api/v2/voice-clones/preview" \
    -H "Authorization: Bearer bna-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "voiceId": "pNInz6obpgDQGcFmaJgB",
      "text": "This is a test with my voice clone for maximum clarity and stability."
    }' \
    --output preview.mp3
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.buena.ai/api/v2/voice-clones/preview",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer bna-your-api-key",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        voiceId: "pNInz6obpgDQGcFmaJgB",
        text: "This is a test with my voice clone for maximum clarity and stability.",
      }),
    }
  );

  // Response is audio binary data
  const audioBlob = await response.blob();
  const audioUrl = URL.createObjectURL(audioBlob);

  // Play the audio
  const audio = new Audio(audioUrl);
  audio.play();
  ```
</CodeGroup>

## Response

The response is the audio file binary data with Content-Type: `audio/mpeg`

No JSON response is returned - the endpoint streams the audio file directly for immediate playback or download.

<ResponseExample>
  ```bash Response Headers theme={null}
  Content-Type: audio/mpeg
  Content-Length: 99328
  Content-Disposition: attachment; filename="preview.mp3"
  ```

  The response body contains the binary audio data that can be played directly or saved to a file.
</ResponseExample>

## Preview Guidelines

### Text Recommendations

<AccordionGroup>
  <Accordion title="Optimal Text Length">
    * **Short test**: 10-30 words for quick quality check
    * **Medium test**: 50-100 words for comprehensive evaluation
    * **Full test**: 100-500 words for complete voice assessment
    * **Avoid**: Very short texts (under 5 words) may not showcase voice quality
  </Accordion>

  <Accordion title="Content Suggestions">
    **For LinkedIn Outreach:**

    ```
    "Hi [Name], I hope you're having a great week! I came across your profile and was impressed by your experience in [industry]. I'd love to connect and share some insights that might be valuable for your work."
    ```

    **For General Testing:**

    ```
    "This is a test of my voice clone quality. I'm checking for naturalness, clarity, and overall sound. The voice should sound smooth and professional."
    ```

    **For Emotional Range:**

    ```
    "I'm excited to share this opportunity with you! It's been an amazing journey, and I believe this could be incredibly valuable. What do you think?"
    ```
  </Accordion>

  <Accordion title="Quality Assessment">
    Listen for:

    * **Naturalness**: Does it sound human and conversational?
    * **Clarity**: Are words pronounced clearly?
    * **Consistency**: Is the voice stable throughout?
    * **Emotion**: Does it convey the intended tone?
    * **Similarity**: Does it match your original voice?
  </Accordion>
</AccordionGroup>

## Voice Settings Optimization

| Setting           | Low (0.0-0.3)             | Medium (0.4-0.7)    | High (0.8-1.0)            |
| ----------------- | ------------------------- | ------------------- | ------------------------- |
| **Stability**     | More expressive, variable | Balanced expression | Very consistent, robotic  |
| **Clarity**       | More natural, may vary    | Good balance        | Maximum similarity, clear |
| **Speaker Boost** | Disabled                  | -                   | Enabled                   |

### Recommended Settings by Use Case

```json theme={null}
{
  "linkedin_professional": {
    "stability": 0.6,
    "clarity": 0.8,
    "use_speaker_boost": true
  },
  "sales_energetic": {
    "stability": 0.4,
    "clarity": 0.7,
    "use_speaker_boost": true
  },
  "casual_friendly": {
    "stability": 0.5,
    "clarity": 0.6,
    "use_speaker_boost": false
  }
}
```

## Error Responses

### Voice Clone Not Found (404)

```json theme={null}
{
  "success": false,
  "error": "Voice not found or not accessible",
  "details": "The specified voice ID does not exist or you don't have access to it"
}
```

### Text Too Long (400)

```json theme={null}
{
  "success": false,
  "error": "Text too long",
  "details": "Text exceeds maximum length of 500 characters"
}
```

### Voice Generation Failed (500)

```json theme={null}
{
  "success": false,
  "error": "Voice generation failed",
  "details": "Failed to generate voice preview. Please try again."
}
```

## Integration Examples

### Voice Quality Testing Workflow

```javascript theme={null}
async function testVoiceQuality(voiceId) {
  const testTexts = [
    "Hello, this is a quick test.",
    "Hi there! I hope you're having a fantastic day. I wanted to reach out because I saw your impressive work at your company.",
    "I'm excited about this opportunity and would love to discuss it further. When might be a good time to chat?",
  ];

  const results = [];

  for (const text of testTexts) {
    try {
      const response = await fetch(
        "https://api.buena.ai/api/v2/voice-clones/preview",
        {
          method: "POST",
          headers: {
            Authorization: "Bearer bna-your-api-key",
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            voiceId: voiceId,
            text: text,
          }),
        }
      );

      const audioBlob = await response.blob();
      const audioUrl = URL.createObjectURL(audioBlob);

      results.push({
        text: text,
        audioUrl: audioUrl,
        size: audioBlob.size,
      });

      console.log(`✅ Generated preview for: "${text.substring(0, 30)}..."`);
    } catch (error) {
      console.error(`❌ Failed to generate preview: ${error.message}`);
    }
  }

  return results;
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="LinkedIn Voice Messages" icon="linkedin" href="/api-reference/linkedin/voice-message">
    Send voice messages via LinkedIn
  </Card>

  <Card title="Voice Clone Settings" icon="cog" href="/api-reference/voice/update-clone">
    Adjust voice generation settings
  </Card>

  <Card title="List Voice Clones" icon="list" href="/api-reference/voice/list-clones">
    View all your voice clones
  </Card>

  <Card title="Voice Best Practices" icon="book" href="/guides/voice-cloning">
    Learn voice optimization tips
  </Card>
</CardGroup>

{" "}
