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

# Preview TTS voice

> Generate a short preview clip for a TTS voice.



## OpenAPI

````yaml /api-reference/openapi.json post /v2/tts/voices/preview
openapi: 3.0.1
info:
  title: Hamsa API
  description: Trying out our transcription and media-to-text APIs
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v2/tts/voices/preview:
    post:
      summary: Preview TTS voice
      description: Generate a short preview clip for a TTS voice.
      parameters:
        - in: query
          name: projectId
          required: true
          description: Project identifier.
          schema:
            type: string
            example: ae6d58c6-c6bd-4ae0-ad74-b8b39c29928b
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TtsVoicePreviewRequest'
      responses:
        '200':
          description: Preview generated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TtsVoicePreviewResponse'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '404':
          description: Voice not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    TtsVoicePreviewRequest:
      type: object
      required:
        - audioUrl
        - audioTranscription
        - language
        - dialectId
        - text
      properties:
        audioUrl:
          type: string
          format: uri
          example: https://cdn.tryhamsa.com/uploads/voice.wav
          description: URL of the uploaded voice sample
        audioTranscription:
          type: string
          minLength: 1
          maxLength: 5000
          example: مرحباً، هذا مثال على التسجيل الصوتي.
          description: Transcription of the uploaded audio sample
        language:
          type: string
          enum:
            - en
            - ar
          example: ar
          description: Language of the preview voice
        dialectId:
          type: string
          format: uuid
          example: 145a7af6-3614-4bb2-be5d-702000d459ab
          description: Dialect identifier (required for preview)
        text:
          type: string
          minLength: 1
          maxLength: 5000
          example: أهلاً بك، هذا مثال لنطق الصوت.
          description: Text to be synthesized using the preview voice
    TtsVoicePreviewResponse:
      type: object
      allOf:
        - $ref: '#/components/schemas/SuccessResponse'
        - type: object
          properties:
            data:
              type: object
              properties:
                audioUrl:
                  type: string
                  format: uri
                  example: https://cdn.tryhamsa.com/previews/preview.wav
    ValidationErrorResponse:
      type: object
      properties:
        code:
          type: integer
          example: 9400
        message:
          type: string
          example: Field must be a string!
        messageKey:
          type: string
          example: FieldMustBeString
    NotFoundResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        code:
          type: integer
          example: 404
        message:
          type: string
          example: Resource not found
    InternalServerErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        code:
          type: integer
          example: 500
        message:
          type: string
          example: Internal server error
    SuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Operation completed successfully
        messageKey:
          type: string
          example: OPERATION_SUCCESSFUL
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````