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

# Audio Transcribe

> Processes an audio file to generate a transcription of the spoken content with support for language detection, translation, and multiple output formats.



## OpenAPI

````yaml POST /v1/audio_transcribe
openapi: 3.1.0
info:
  title: Musicgpt API
  version: 1.0.0
  description: API for retrieving conversion details by ID.
servers:
  - url: https://api.musicgpt.com/api/public
    description: Production server
security: []
paths:
  /v1/audio_transcribe:
    post:
      summary: Transcribe Audio to Text
      description: >-
        Processes an audio file to generate a transcription of the spoken
        content with support for language detection, translation, and multiple
        output formats.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                audio_url:
                  type: string
                  description: URL of the audio file to transcribe.
                  example: https://example.com/audio.mp3
                audio_file:
                  type: string
                  format: binary
                  description: Audio file to upload and process directly.
                language:
                  type: string
                  description: Language spoken in the audio (empty for auto-detection).
                  example: en
                translate:
                  type: boolean
                  description: Whether to translate the transcription to English.
                  example: false
                transcription_format:
                  type: string
                  description: Format of the transcribed output.
                  enum:
                    - plain_text
                    - formatted_text
                    - srt
                    - vtt
                  example: plain_text
                translation_format:
                  type: string
                  description: Format of the translated output (currently unused).
                  enum:
                    - plain_text
                    - formatted_text
                    - srt
                    - vtt
                  example: plain_text
                word_timestamps:
                  type: boolean
                  description: Whether to include word-level timestamps.
                  example: false
                webhook_url:
                  type: string
                  description: Callback URL for async processing results.
                  example: http://your-webhook-url.com/callback
              anyOf:
                - required:
                    - audio_url
                - required:
                    - audio_file
      responses:
        '200':
          description: Successfully initiated transcription
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  task_id:
                    type: string
                  conversion_id:
                    type: string
                  eta:
                    type: integer
                  credit_estimate:
                    type: number
                    format: float
                  message:
                    type: string
                example:
                  success: true
                  task_id: transcribe123
                  conversion_id: conv456
                  eta: -1
                  credit_estimate: 100.1
                  message: Successfully published to queue
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Either audio_url or audio_file must be provided.
        '500':
          description: Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: Internal Server Error
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: >-
            import requests


            url = "https://api.musicgpt.com/api/public/v1/audio_transcribe"

            headers = {"Authorization": "<<<api key>>>"}


            # Option 1: URL

            payload = {
                "audio_url": "https://example.com/audio.mp3",
                "language": "en",
                "translate": True,
                "transcription_format": "srt",
                "word_timestamps": True
            }

            response = requests.post(url, headers=headers, data=payload)

            print(response.json())


            # Option 2: File Upload

            # payload = {

            #     "language": "en",

            #     "translate": False,

            #     "transcription_format": "plain_text",

            #     "word_timestamps": True

            # }

            # with open("audio.mp3", "rb") as f:

            #     files = {"audio_file": f}

            #     response = requests.post(url, headers=headers, data=payload,
            files=files)

            # print(response.json())
        - lang: PHP
          source: |-
            <?php
            $url = 'https://api.musicgpt.com/api/public/v1/audio_transcribe';
            $headers = ['Authorization: <<<api key>>>'];

            // Option 1: URL
            $data = [
                'audio_url' => 'https://example.com/audio.mp3',
                'language' => 'en',
                'translate' => true,
                'transcription_format' => 'srt',
                'word_timestamps' => true
            ];
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
            echo $response;

            // Option 2: File Upload
            $data = [
                'language' => 'en',
                'translate' => false,
                'transcription_format' => 'plain_text',
                'word_timestamps' => true,
                'audio_file' => new CURLFile('audio.mp3')
            ];
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
            echo $response;
        - lang: Go
          source: "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\turl := \"https://api.musicgpt.com/api/public/v1/audio_transcribe\"\n\tapiKey := \"<<<api key>>>\"\n\n\t// Option 1: URL\n\tpayload := \"audio_url=https://example.com/audio.mp3&language=en&translate=true&transcription_format=srt&word_timestamps=true\"\n\treq, _ := http.NewRequest(\"POST\", url, strings.NewReader(payload))\n\treq.Header.Add(\"Authorization\", apiKey)\n\tres, _ := http.DefaultClient.Do(req)\n\tdefer res.Body.Close()\n\tbody, _ := io.ReadAll(res.Body)\n\tfmt.Println(string(body))\n\n\t// Option 2: File Upload\n\tfile, _ := os.Open(\"audio.mp3\")\n\tdefer file.Close()\n\tbodyBuf := &bytes.Buffer{}\n\twriter := multipart.NewWriter(bodyBuf)\n\twriter.WriteField(\"language\", \"en\")\n\twriter.WriteField(\"translate\", \"false\")\n\twriter.WriteField(\"transcription_format\", \"plain_text\")\n\twriter.WriteField(\"word_timestamps\", \"true\")\n\tpart, _ := writer.CreateFormFile(\"audio_file\", \"audio.mp3\")\n\tio.Copy(part, file)\n\twriter.Close()\n\n\treq, _ = http.NewRequest(\"POST\", url, bodyBuf)\n\treq.Header.Add(\"Authorization\", apiKey)\n\treq.Header.Add(\"Content-Type\", writer.FormDataContentType())\n\tres, _ = http.DefaultClient.Do(req)\n\tdefer res.Body.Close()\n\tbody, _ = io.ReadAll(res.Body)\n\tfmt.Println(string(body))\n}"
        - lang: Java
          source: // Java example omitted for brevity. Request if needed.
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````