text-to-ambience
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
main.ts
https://jubertioai--aa6a5c2ca47611f0bbb20224a6c84d84.web.val.run
A simple web application that allows users to search for audio files using the Freesound API and play them in a loop.
- Simple Google-like search interface
- Server-side Freesound API integration
- High-quality audio preview playback
- Automatic looping
- Replace previous audio with new search results
backend/index.ts
- Main Hono server with API routesfrontend/index.html
- Main HTML interfacefrontend/index.js
- Client-side JavaScript for audio playbackfrontend/style.css
- Styling
GET /
- Serves the main HTML interfaceGET /api/search?q={query}
- Search for audio files and return playback URL
The application uses the Freesound API. You'll need to set the FREESOUND_API_KEY
environment variable with your Freesound API key.
- Go to https://freesound.org/apiv2/apply/
- Create an account or log in
- Apply for an API key
- Once approved, add your API key to the Val Town environment variables as
FREESOUND_API_KEY
- Enter a search term in the search box (e.g., "piano", "rain", "drums")
- Click "Search" or press Enter
- The app will find the top result and automatically start playing it in a loop
- Use the play/pause and stop buttons to control playback
- Search for new sounds to replace the current audio
- 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