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

# Create translation

> استخدم CometAPI POST /v1/audio/translations لترجمة الصوت المنطوق إلى نص إنجليزي باستخدام نموذج ترجمة محدد وتنسيق استجابة محدد.

استخدم نقطة النهاية هذه لترجمة الصوت المنطوق إلى نص إنجليزي. وهي مناسبة لقوائم انتظار الدعم متعددة اللغات، ومراجعة الوسائط، وسير العمل التي تحتاج إلى نسخة نصية واحدة باللغة الإنجليزية من ملف صوتي بلغة أخرى.

## الطلب الأول

أرسل ملفًا صوتيًا مدعومًا مع `model` و`file`. استخدم عينة قصيرة أولًا حتى تتمكن من التحقق من معالجة الرفع، واكتشاف اللغة، وتحليل المخرجات.

## قراءة الاستجابة

تتضمن الاستجابة الافتراضية `text` الإنجليزي المترجم. إذا طلبت تنسيق استجابة مختلفًا، فحلّل الاستجابة وفقًا لذلك التنسيق.

## الخطوات التالية

* استخدم [Create Transcription](/api/audio/create-transcription) عندما تحتاج إلى نص باللغة الأصلية.
* استخدم [Create Speech](/api/audio/create-speech) عندما تحتاج إلى إنشاء صوت من نص.


## OpenAPI

````yaml api/openapi/audio/post-create-translation.openapi.json POST /v1/audio/translations
openapi: 3.1.0
info:
  title: Create translation API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/audio/translations:
    post:
      summary: Create translation
      operationId: create_translation
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  format: binary
                  type: string
                  description: >-
                    The audio file to translate. Supported formats: flac, mp3,
                    mp4, mpeg, mpga, m4a, ogg, wav, webm.
                model:
                  type: string
                  description: >-
                    The audio translation model to use. Choose a current speech
                    model from the [Models page](/overview/models).
                  default: whisper-1
                prompt:
                  type: string
                  description: >-
                    Optional text to guide the model's style or continue a
                    previous audio segment. The prompt should be in English.
                response_format:
                  type: string
                  description: The output format for the translation.
                  enum:
                    - json
                    - text
                    - srt
                    - verbose_json
                    - vtt
                  default: json
                temperature:
                  type: number
                  description: >-
                    Sampling temperature between 0 and 1. Higher values produce
                    more random output; lower values are more focused. When set
                    to 0, the model auto-adjusts temperature using log
                    probability.
                  minimum: 0
                  maximum: 1
                  default: 0
              required:
                - file
                - model
      responses:
        '200':
          description: The translation result in English.
          content:
            application/json:
              schema:
                type: object
                required:
                  - text
                properties:
                  text:
                    type: string
                    description: The translated text in English.
              examples:
                Default:
                  summary: Translation result
                  value:
                    text: Hello, welcome to CometAPI.
      x-codeSamples:
        - lang: python
          label: Create translation
          source: |-
            import os
            from openai import OpenAI

            client = OpenAI(
                api_key=os.environ["COMETAPI_KEY"],
                base_url="https://api.cometapi.com/v1"
            )

            audio_file = open("audio.mp3", "rb")
            translation = client.audio.translations.create(
                model="whisper-1",
                file=audio_file
            )
            print(translation.text)
        - lang: javascript
          label: Create translation
          source: |-
            import OpenAI from "openai";
            import fs from "fs";

            const client = new OpenAI({
              apiKey: process.env.COMETAPI_KEY,
              baseURL: "https://api.cometapi.com/v1"
            });

            const translation = await client.audio.translations.create({
              model: "whisper-1",
              file: fs.createReadStream("audio.mp3")
            });
            console.log(translation.text);
        - lang: shell
          label: Create translation
          source: |-
            curl -X POST https://api.cometapi.com/v1/audio/translations \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -F model="whisper-1" \
              -F file="@audio.mp3"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````