### Install Sonilo Client Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Install the core library via pip. ```bash pip install sonilo ``` -------------------------------- ### Install and Use Sonilo CLI Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Install the command-line interface wrapper for music and SFX generation. ```bash pip install sonilo-cli sonilo text-to-music --prompt "warm lo-fi piano, rain" --duration 30 ``` -------------------------------- ### Compose with segments Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Defines a composition using contiguous segments with specific start times and prompts. ```python client.text_to_music.generate( prompt="epic trailer", duration=60, segments=[ {"start": 0, "prompt": "soft intro", "label": "intro"}, {"start": 20, "prompt": "building tension", "label": "verse"}, {"start": 40, "prompt": "full orchestra", "label": "chorus"}, ], ) ``` -------------------------------- ### Configure Ducking and Output Format Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Customize async video-to-music generation with ducking and specific output formats like WAV. ```python result = client.video_to_music.generate_async( video="my_video.mp4", preserve_speech=True, output_format="wav", # ducking defaults on in async — pass ducking=False to disable ) result.save("track.wav") if result.ducked: result.save("ducked.wav", which="ducked") ``` -------------------------------- ### Generate Music from Text Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Initialize the client and generate a music track from a text prompt. ```python from sonilo import Sonilo client = Sonilo() # reads SONILO_API_KEY track = client.text_to_music.generate( prompt="cinematic orchestral score", duration=60, ) track.save("output.mp3") print(track.title) ``` -------------------------------- ### Configure Authentication Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Set the API key via environment variable or pass it directly to the client constructor. ```bash export SONILO_API_KEY=sk_... ``` ```python client = Sonilo() # reads SONILO_API_KEY client = Sonilo(api_key="sk_...") # or pass it directly ``` -------------------------------- ### client.account.services() Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Retrieves a list of available services for the account. ```APIDOC ## client.account.services() ### Description Retrieves the list of services available to the current account. ### Method SDK Method ### Parameters None ``` -------------------------------- ### Generate and stream asynchronously Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Demonstrates asynchronous client usage for both generation and streaming operations. ```python from sonilo import AsyncSonilo async with AsyncSonilo() as client: track = await client.text_to_music.generate(prompt="lofi", duration=30) async for event in client.text_to_music.stream(prompt="lofi", duration=30): ... ``` -------------------------------- ### client.video_to_sound.generate Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generates a mixed music bed and sound effects for a video clip, returning the mixed audio. ```APIDOC ## client.video_to_sound.generate ### Description Generates a mixed music bed and sound effects for a video clip, returning the mixed audio. ### Parameters - **video_url** (str) - Required - URL of the video. - **music_prompt** (str) - Required - Description of the music. - **sfx_prompt** (str) - Required - Description of the sound effects. - **ducking** (bool) - Optional - Whether to dip music under speech (default: True). ``` -------------------------------- ### client.video_to_video_music.generate Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generates music for a video and returns a re-hosted video with the audio muxed in. ```APIDOC ## client.video_to_video_music.generate ### Description Generates music for a video and returns a re-hosted video with the audio muxed in. ### Parameters - **video** (str/bytes/file) - Required - Path, bytes, or open file object of the video. - **video_url** (str) - Optional - URL of the video. - **prompt** (str) - Required - Description of the music to generate. - **preserve_speech** (bool) - Optional - Whether to preserve speech from the source video. ``` -------------------------------- ### client.video_to_video_sfx.generate Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generates sound effects for specific segments of a video and returns a re-hosted video with the audio muxed in. ```APIDOC ## client.video_to_video_sfx.generate ### Description Generates sound effects for specific segments of a video and returns a re-hosted video with the audio muxed in. ### Parameters - **video** (str/bytes/file) - Required - Path, bytes, or open file object of the video. - **segments** (list) - Required - List of dictionaries containing 'start', 'end', and 'prompt' for sound effects. ``` -------------------------------- ### Manage manual sound effect tasks Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Manually submits a video-to-sfx task and polls for completion with custom intervals. ```python task = client.video_to_sfx.submit( video="clip.mp4", segments=[{"start": 0, "end": 2.5, "prompt": "footsteps on gravel"}], audio_format="wav", ) result = client.tasks.wait(task.task_id, poll_interval=2.0, timeout=600.0) result.save("audio.wav") # video-to-sfx returns the generated audio only ``` -------------------------------- ### video_to_sfx.submit Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Submits a video-to-sfx generation task. ```APIDOC ## client.video_to_sfx.submit ### Description Submits a video file for sound effect generation based on segments. ### Parameters - **video** (str) - Required - Path or identifier for the video file. - **segments** (list) - Required - List of segments with 'start', 'end', and 'prompt'. - **audio_format** (str) - Optional - The desired output format (e.g., 'wav'). ``` -------------------------------- ### Retrieve account services and usage Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Use these methods to check available services and monitor API usage over a specified period. ```python client.account.services() client.account.usage(days=7) ``` -------------------------------- ### Generate video-to-video music and sound effects Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Use the video_to_video_music and video_to_video_sfx endpoints to generate and mux audio into video files. ```python music = client.video_to_video_music.generate( video="my_video.mp4", # path, bytes, open file, or use video_url= prompt="cinematic orchestral swell", preserve_speech=True, ) music.save("scored.mp4") sfx = client.video_to_video_sfx.generate( video="my_video.mp4", segments=[{"start": 0, "end": 2, "prompt": "footsteps on gravel"}], ) sfx.save("with_sfx.mp4") ``` -------------------------------- ### Preserve Speech in Async Video-to-Music Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Use async generation to preserve speech and retrieve separate audio stems. ```python result = client.video_to_music.generate_async( video="my_video.mp4", prompt="upbeat", preserve_speech=True, # implies mode="async"; omit mode to let it auto-select ) result.save("mix.m4a") # result.audio[0] — the full mix result.save("vocals.m4a", which="vocals") result.save("video.mp4", which="mux") # generated music muxed with the preserved speech print(result.title.title if result.title else None) ``` -------------------------------- ### text_to_sfx.generate Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generates sound effects synchronously by wrapping submission and polling. ```APIDOC ## client.text_to_sfx.generate ### Description Submits a sound effect generation request and polls until completion. ### Parameters - **prompt** (str) - Required - Description of the sound effect. - **duration** (int) - Required - Duration in seconds. ``` -------------------------------- ### client.account.usage(days=7) Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Retrieves the usage statistics for the account over a specified number of days. ```APIDOC ## client.account.usage(days=7) ### Description Fetches usage data for the account for the specified number of days. ### Method SDK Method ### Parameters #### Arguments - **days** (int) - Optional - The number of days to retrieve usage for. Defaults to 7. ``` -------------------------------- ### Generate Music from Video Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generate music based on a video file or URL. ```python track = client.video_to_music.generate(video="my_video.mp4", prompt="upbeat") # or bytes / an open binary file, or a hosted URL: track = client.video_to_music.generate(video_url="https://example.com/clip.mp4") ``` -------------------------------- ### text_to_music.generate Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generates music based on a prompt, supporting optional segment-based composition. ```APIDOC ## client.text_to_music.generate ### Description Generates a music track based on the provided prompt and duration. Supports complex compositions using segments. ### Parameters - **prompt** (str) - Required - The description of the music to generate. - **duration** (int) - Required - The length of the track in seconds. - **segments** (list) - Optional - A list of dictionaries defining composition segments with 'start', 'prompt', and 'label'. ``` -------------------------------- ### Generate mixed video-to-sound output Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Generate a combined music and sound effect track for a video clip using a single request. ```python from sonilo import Sonilo client = Sonilo() result = client.video_to_sound.generate( video_url="https://example.com/clip.mp4", music_prompt="uplifting orchestral score", sfx_prompt="match the on-screen action", ) result.save("soundtrack.wav") ``` -------------------------------- ### text_to_music.stream Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Streams audio chunks as they are generated. ```APIDOC ## client.text_to_music.stream ### Description Streams audio generation events. Returns an iterator yielding events with 'type' and 'data' fields. ### Parameters - **prompt** (str) - Required - The description of the music to generate. - **duration** (int) - Required - The length of the track in seconds. ``` -------------------------------- ### Stream audio chunks Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Processes audio data as it arrives from the server using a synchronous generator. ```python for event in client.text_to_music.stream(prompt="lofi", duration=30): if event["type"] == "audio_chunk": handle(event["data"]) # bytes, as they arrive ``` -------------------------------- ### Save individual audio stems Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Extract and save individual music or sound effect stems from a generated result. ```python result.save_stem("music.m4a", which="music") result.save_stem("sfx.wav", which="sfx") ``` -------------------------------- ### Manual Async Task Polling Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Manually submit a task and poll for completion using the task parser. ```python from sonilo.resources.tasks import parse_music_result task = client.video_to_music.submit(video_url="https://example.com/clip.mp4", preserve_speech=True) result = client.tasks.wait( task.task_id, parser=parse_music_result, # required: tasks.wait()/get() default to the SFX parser ) ``` -------------------------------- ### tasks.wait Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Polls for the completion of an asynchronous task. ```APIDOC ## client.tasks.wait ### Description Polls a task until it completes, fails, or times out. ### Parameters - **task_id** (str) - Required - The ID of the task to poll. - **poll_interval** (float) - Optional - Time in seconds between polls. - **timeout** (float) - Optional - Maximum time to wait in seconds. ``` -------------------------------- ### Generate sound effects Source: https://github.com/sonilo-ai/sonilo-python/blob/main/README.md Uses the generate method to submit and poll for sound effect results automatically. ```python from sonilo import Sonilo with Sonilo() as client: result = client.text_to_sfx.generate(prompt="glass shattering", duration=5) result.save("sfx.m4a") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.