Audio Predictions

The audio component provides methods for processing and analyzing audio files using VLM Run’s models.

Process Audio

import { VlmRun } from "vlmrun";

const client = new VlmRun({
  apiKey: "your-api-key",
});

// Upload and process an audio file
const file = await client.files.upload({
  filePath: "path/to/audio.mp3",
});

// Process audio using URL
const response = await client.audio.generate({
  fileId: file.id,
  domain: "audio.transcription",
});

TypeScript Interfaces

interface FilePredictionParams extends PredictionGenerateParams {
  batch?: boolean;
  fileId?: string;
  url?: string;
}

Error Handling

try {
  const response = await client.audio.generate({
    url: "invalid-url",
    model: "vlm-1",
  });
} catch (error) {
  if (error instanceof ApiError) {
    console.error("API Error:", error.message);
    // Handle API-specific errors
  } else {
    console.error("File system error:", error);
    // Handle local file system errors
  }
}

Best Practices

  1. Audio Formats

    • Supported formats: MP3, WAV
    • Ensure proper audio quality
    • Consider file size limits
  2. Performance

    • Use URLs for remote audio files when possible
    • Handle timeouts appropriately
    • Consider audio length and complexity
  3. Error Handling

    • Validate audio files before processing
    • Handle both API and file system errors
    • Implement proper error recovery