Freesound Audio Search

A simple web application that allows users to search for audio files using the Freesound API and play them in a loop.

Features

  • Simple Google-like search interface
  • Server-side Freesound API integration
  • High-quality audio preview playback
  • Automatic looping
  • Replace previous audio with new search results

Structure

  • backend/index.ts - Main Hono server with API routes
  • frontend/index.html - Main HTML interface
  • frontend/index.js - Client-side JavaScript for audio playback
  • frontend/style.css - Styling

API Endpoints

  • GET / - Serves the main HTML interface
  • GET /api/search?q={query} - Search for audio files and return playback URL

Setup

The application uses the Freesound API. You'll need to set the FREESOUND_API_KEY environment variable with your Freesound API key.

Getting a Freesound API Key

  1. Go to https://freesound.org/apiv2/apply/
  2. Create an account or log in
  3. Apply for an API key
  4. Once approved, add your API key to the Val Town environment variables as FREESOUND_API_KEY

Usage

  1. Enter a search term in the search box (e.g., "piano", "rain", "drums")
  2. Click "Search" or press Enter
  3. The app will find the top result and automatically start playing it in a loop
  4. Use the play/pause and stop buttons to control playback
  5. Search for new sounds to replace the current audio

Features

  • Simple Interface: Google-like search experience
  • High Quality Audio: Automatically selects the highest quality preview available
  • Automatic Looping: Audio plays continuously until stopped or replaced
  • Progress Indicator: Visual progress bar shows playback position
  • Error Handling: Clear error messages for API issues or missing audio
  • Responsive Design: Works on desktop and mobile devices