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

# Audio - Voice

> Analyze an **audio file** to determine if it was generated by an AI *voice* model.

This endpoint is only appropriate when you are looking for ai versus human generated voices. It is not appropriate for music (including singing).

**Warning: This endpoint can take up two minutes for long duration audio files or if our backend is spinning up additional processing nodes. Please set a two minute timeout in your client.**



## OpenAPI

````yaml api-reference/openapi.yaml post /v1/reports/voice
openapi: 3.1.0
info:
  title: AIORNOT API
  summary: |2-

            Welcome to AI or Not`s documentation, the developer guide to discerning digital authenticity!
            
  termsOfService: https://aiornot.com/terms-of-service
  contact:
    name: AIORNOT
    url: https://aiornot.com/
    email: support@aiornot.com
  version: 5.0.2
servers:
  - url: https://api.aiornot.com
    description: Production environment
security: []
paths:
  /v1/reports/voice:
    post:
      tags:
        - Reports by Modality
      summary: Audio - Voice
      description: >-
        Analyze an **audio file** to determine if it was generated by an AI
        *voice* model.


        This endpoint is only appropriate when you are looking for ai versus
        human generated voices. It is not appropriate for music (including
        singing).


        **Warning: This endpoint can take up two minutes for long duration audio
        files or if our backend is spinning up additional processing nodes.
        Please set a two minute timeout in your client.**
      operationId: get_voice_report_reports_voice_post
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_get_voice_report_reports_voice_post'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceReportResponse'
      security:
        - HTTPBearer: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |
            import os, requests


            # Set API key ENV variable or replace with your own API key
            API_KEY = os.getenv("AIORNOT_API_KEY")
            VOICE_ENDPOINT = "https://api.aiornot.com/v1/reports/voice"

            with open("audio.mp3", "rb") as audio_file:
                files = {"file": audio_file}
                resp = requests.post(
                    VOICE_ENDPOINT, 
                    headers={"Authorization": f"Bearer {API_KEY}"},
                    files=files,
                    timeout=120
                )
                if resp.status_code != 200:
                    raise Exception(f"Failed to analyze image: {resp.status_code} {resp.text}")

                print(resp.json())
        - lang: curl
          label: cURL
          source: |
            curl --request POST \
              --url https://api.aiornot.com/v1/reports/voice \
              --header 'Authorization: Bearer $AIORNOT_API_KEY' \
              --form 'file=@audio.mp3' \
              --max-time 120
        - lang: javascript
          label: JavaScript
          source: |
            const fs = require('fs');
            const FormData = require('form-data');
            const fetch = require('node-fetch');

            const API_KEY = process.env.AIORNOT_API_KEY;
            const VOICE_ENDPOINT = 'https://api.aiornot.com/v1/reports/voice';

            const form = new FormData();
            form.append('file', fs.createReadStream('audio.mp3'));

            fetch(VOICE_ENDPOINT, {
              method: 'POST',
              headers: {
                'Authorization': `Bearer ${API_KEY}`,
                ...form.getHeaders()
              },
              body: form,
              timeout: 120000
            })
              .then(response => {
                if (!response.ok) {
                  throw new Error(`Failed to analyze voice: ${response.status} ${response.statusText}`);
                }
                return response.json();
              })
              .then(data => console.log(data))
              .catch(error => console.error('Error:', error));
        - lang: php
          label: PHP
          source: |
            <?php

            $API_KEY = getenv('AIORNOT_API_KEY');
            $VOICE_ENDPOINT = 'https://api.aiornot.com/v1/reports/voice';

            $curl = curl_init();

            $audioFile = new CURLFile('audio.mp3', 'audio/mpeg', 'file');

            curl_setopt_array($curl, [
              CURLOPT_URL => $VOICE_ENDPOINT,
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_TIMEOUT => 120,
              CURLOPT_POST => true,
              CURLOPT_POSTFIELDS => [
                'file' => $audioFile
              ],
              CURLOPT_HTTPHEADER => [
                "Authorization: Bearer $API_KEY"
              ],
            ]);

            $response = curl_exec($curl);
            $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } elseif ($httpCode !== 200) {
              echo "Failed to analyze voice: HTTP $httpCode - $response";
            } else {
              $data = json_decode($response, true);
              print_r($data);
            }
        - lang: go
          label: Go
          source: |
            package main

            import (
              "bytes"
              "fmt"
              "io"
              "io/ioutil"
              "mime/multipart"
              "net/http"
              "os"
              "time"
            )

            func main() {
              APIKey := os.Getenv("AIORNOT_API_KEY")
              voiceEndpoint := "https://api.aiornot.com/v1/reports/voice"

              file, err := os.Open("audio.mp3")
              if err != nil {
                panic(err)
              }
              defer file.Close()

              var requestBody bytes.Buffer
              writer := multipart.NewWriter(&requestBody)

              part, err := writer.CreateFormFile("file", "audio.mp3")
              if err != nil {
                panic(err)
              }

              _, err = io.Copy(part, file)
              if err != nil {
                panic(err)
              }

              err = writer.Close()
              if err != nil {
                panic(err)
              }

              client := &http.Client{
                Timeout: 120 * time.Second,
              }

              req, err := http.NewRequest("POST", voiceEndpoint, &requestBody)
              if err != nil {
                panic(err)
              }

              req.Header.Set("Authorization", "Bearer "+APIKey)
              req.Header.Set("Content-Type", writer.FormDataContentType())

              resp, err := client.Do(req)
              if err != nil {
                panic(err)
              }
              defer resp.Body.Close()

              body, err := ioutil.ReadAll(resp.Body)
              if err != nil {
                panic(err)
              }

              if resp.StatusCode != 200 {
                fmt.Printf("Failed to analyze voice: %d %s\n", resp.StatusCode, string(body))
                return
              }

              fmt.Println(string(body))
            }
        - lang: java
          label: Java
          source: |
            import java.io.File;
            import java.io.IOException;
            import java.util.concurrent.TimeUnit;
            import okhttp3.*;

            public class VoiceAnalysis {
                public static void main(String[] args) {
                    String apiKey = System.getenv("AIORNOT_API_KEY");
                    String voiceEndpoint = "https://api.aiornot.com/v1/reports/voice";
                    
                    OkHttpClient client = new OkHttpClient.Builder()
                        .readTimeout(120, TimeUnit.SECONDS)
                        .build();
                    
                    File audioFile = new File("audio.mp3");
                    
                    RequestBody requestBody = new MultipartBody.Builder()
                        .setType(MultipartBody.FORM)
                        .addFormDataPart("file", audioFile.getName(),
                            RequestBody.create(MediaType.parse("audio/mpeg"), audioFile))
                        .build();
                    
                    Request request = new Request.Builder()
                        .url(voiceEndpoint)
                        .header("Authorization", "Bearer " + apiKey)
                        .post(requestBody)
                        .build();
                    
                    try {
                        Response response = client.newCall(request).execute();
                        if (!response.isSuccessful()) {
                            System.err.println("Failed to analyze voice: " + response.code() + " " + response.body().string());
                        } else {
                            System.out.println(response.body().string());
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
components:
  schemas:
    Body_get_voice_report_reports_voice_post:
      properties:
        file:
          type: string
          format: binary
          title: File
          description: The audio file to analyze. Must be a valid audio file.
      type: object
      required:
        - file
      title: Body_get_voice_report_reports_voice_post
    VoiceReportResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        created_at:
          type: string
          format: date-time
          title: Created At
        report:
          $ref: '#/components/schemas/ShareVoiceReport'
      type: object
      required:
        - id
        - report
      title: VoiceReportResponse
    ShareVoiceReport:
      properties:
        verdict:
          $ref: '#/components/schemas/AIONGenerateVerdict'
        confidence:
          type: number
          title: Confidence
          example: 0.95
          minimum: 0
          maximum: 1
        duration:
          type: integer
          title: Duration
          example: 120
        total_bytes:
          type: integer
          title: Total Bytes
          example: 362594
        md5:
          type: string
          title: Md5
          example: db36d923800f6ca6b7f87cff8a19d1d1
      type: object
      required:
        - verdict
        - confidence
        - duration
        - total_bytes
        - md5
      title: ShareVoiceReport
    AIONGenerateVerdict:
      type: string
      enum:
        - ai
        - human
      title: AIONGenerateVerdict
      description: Generate verdict.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        Your [API key](https://www.aiornot.com/dashboard/api) as the `Bearer`
        token in the `Authorization` header.

````