arioso.cover#
Cover every song in a folder: lyrics, one cover call per song, every take saved, resumable.
cover_folder() is the loop around one-song generate(audio_input=...) that a folder
job needs. Per source file it:
skips the song when the folder’s manifest already records it as done or refused;
reuses the cover task the manifest recorded for it, when a run stopped between submitting and saving (so a crash or a re-run never pays twice), or else
transcribes its lyrics (
transcribe, defaultvocal_lyrics(): the vocal stem fromdenote.separate, transcribed byscribed; only for a platform that takes lyrics), so the cover keeps the words; no words heard makes it instrumental; and submits one cover, recording the task id in the manifest before waiting for it;waits for it and saves every take as
<stem> (<platform> N).<ext>indst, and checks them against the source when asked (assess, e.g.arioso.closeness.cover_closeness());records the outcome in the manifest (
dst/covers.jsonl, JSON lines, the last line of a song wins):done,refused(aCatalogMatchError, final) orerror(tried again on the next run: by reusing its task once, then by submitting anew).
>>> from arioso.base import AudioResult, Song
>>> import tempfile, pathlib
>>> src, dst = pathlib.Path(tempfile.mkdtemp()), pathlib.Path(tempfile.mkdtemp())
>>> _ = (src / "Lullaby.wav").write_bytes(b"RIFF")
>>> def fake(prompt, **kw): # a platform that answers at once, with two takes
... return [Song(id=f"t{i}", status="complete", platform="fake",
... audio=AudioResult(audio_bytes=b"ID3", format="mp3")) for i in (1, 2)]
>>> [r["outcome"] for r in cover_folder(src, dst, platform="fake", generate=fake,
... transcribe=lambda p: "hush now")]
['done']
>>> sorted(p.name for p in dst.iterdir())
['Lullaby (fake 1).mp3', 'Lullaby (fake 2).mp3', 'covers.jsonl']
>>> cover_folder(src, dst, platform="fake", generate=fake, transcribe=None) # resumed
[]
Module Attributes
The audio files |
|
The manifest's file name, inside the target folder. |
|
Outcomes that end a song's job; |
|
a folder cover is meant to keep each song (the #69 run used 0.9). |
|
seconds between status checks, and the most to wait. |
|
seconds between status checks, and the most to wait. |
|
|
Functions
|
Cover every audio file in |
|
The cover call's keyword arguments for one song (unified names). |
|
The last record of each song in a manifest (JSON lines), by source file name. |
|
Write each take as |
|
The words sung in |
|
|
- arioso.cover.AUDIO_EXTENSIONS = ('.wav', '.mp3', '.m4a', '.aac', '.flac', '.ogg', '.aiff', '.aif')#
The audio files
cover_folder()picks up from the source folder.
- arioso.cover.AUTO = 'auto'#
vocal_lyrics()when the platform takes lyrics, else none.- Type:
transcribe’s default
- arioso.cover.DFLT_MANIFEST = 'covers.jsonl'#
The manifest’s file name, inside the target folder.
- arioso.cover.DFLT_POLL_INTERVAL = 15.0#
seconds between status checks, and the most to wait.
- Type:
Waiting for a hosted cover
- arioso.cover.DFLT_STRENGTH = 0.9#
a folder cover is meant to keep each song (the #69 run used 0.9).
- Type:
How much the source shapes the cover. Higher than
tools.DFLT_AUDIO_WEIGHT(0.5)
- arioso.cover.DFLT_TIMEOUT = 1200.0#
seconds between status checks, and the most to wait.
- Type:
Waiting for a hosted cover
- arioso.cover.FINAL_OUTCOMES = ('done', 'refused')#
Outcomes that end a song’s job;
erroris tried again on the next run.
- arioso.cover.cover_folder(src, dst, *, platform='sunoapi', audio_input_strength=0.9, transcribe='auto', style=None, only=None, params=<function cover_params>, generate=None, wait=<function wait_for_songs>, manifest='covers.jsonl', extensions=('.wav', '.mp3', '.m4a', '.aac', '.flac', '.ogg', '.aiff', '.aif'), assess=None, **generate_kwargs)[source]#
Cover every audio file in
srcwithplatform, takes saved indst.Returns the records written this run (one per song attempted; songs the manifest already holds as done or refused are skipped). See the module docstring.
- Parameters:
src – The folder of source songs (files with one of
extensions).dst – The folder for the takes and the manifest (created if missing).
platform (
str) – An arioso platform that takesaudio_input.audio_input_strength (
float) – How much the source shapes the cover, 0-1.transcribe (
Union[Callable,str,None]) –(path) -> lyrics;""makes the cover instrumental,Nonesends no lyrics. The default usesvocal_lyrics()whenplatformtakes lyrics, and none otherwise.style (
Union[str,Callable,None]) – The style for every song, or(path) -> style;Nonesends none.only (
Optional[Iterable[str]]) – Source stems to cover (default every file).params (
Callable) –(path, *, lyrics, style, strength) -> kwargsfor the cover call (defaultcover_params()); parametersplatformdoes not take are dropped.generate (
Callable) –(prompt, **kwargs) -> list[Song]; defaultarioso.generate_many.wait (
Callable) –(songs) -> songs, all complete (defaultwait_for_songs()).manifest (
str) – The manifest’s name indst.assess (
Optional[Callable]) –(source_path, take_paths) -> dict, run on each song’s saved takes and kept in its record asassessment(e.g.functools.partial(arioso.closeness.cover_closeness, references=<the other sources>)); a failure is recorded asassessment_errorand does not undo the takes.**generate_kwargs – Passed to every cover call (
model,vocal_gender, …).
- Return type:
- arioso.cover.cover_params(path, *, lyrics, style, strength)[source]#
The cover call’s keyword arguments for one song (unified names).
lyrics=""(no words heard) asks for an instrumental;Nonesends nothing.- Return type:
- arioso.cover.read_manifest(path)[source]#
The last record of each song in a manifest (JSON lines), by source file name.
A line that does not parse (a run killed mid-write) is skipped.
- Return type:
- arioso.cover.save_takes(songs, folder, stem, *, platform)[source]#
Write each take as
<stem> (<platform> N).<ext>; returns their file names.- Return type:
- arioso.cover.vocal_lyrics(path, *, separate=None, transcribe=None, **transcribe_kwargs)[source]#
The words sung in
path: its vocal stem (denote.separate), transcribed.One line per transcript segment;
""when no words are heard.separateandtranscribedefault todenote.separateandscribed.transcribe(both imported only here;pip install arioso[cover]);transcribe_kwargsgo to the transcriber (backend,model,language, …).- Return type:
- arioso.cover.wait_for_songs(songs, *, poll_interval=15.0, timeout=1200.0, check=None)[source]#
songsonce all complete, polled withcheck(defaultarioso.check_status).Songs already complete (a local platform) come back at once. Raises
TimeoutErrorpasttimeout, andRuntimeErroron a song in error.- Return type: