Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: Stable Audio Live Multiplayer
|
3 |
-
emoji:
|
4 |
colorFrom: pink
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
@@ -9,4 +9,70 @@ app_file: app.py
|
|
9 |
pinned: true
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: 🎧Stable Audio🔊 - 💾Live Multiplayer🎼
|
3 |
+
emoji: 🎙️🔊🎧
|
4 |
colorFrom: pink
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
|
|
9 |
pinned: true
|
10 |
---
|
11 |
|
12 |
+
The code achieves this functionality through the following functions:
|
13 |
+
|
14 |
+
generate_audio function:
|
15 |
+
|
16 |
+
This function is responsible for generating the audio based on the provided prompt and parameters.
|
17 |
+
It saves the generated audio file with a unique filename in the specified directory (/data/output_{random_uuid}.wav).
|
18 |
+
It also saves the corresponding prompt in a text file with the same unique filename (/data/output_{random_uuid}.txt).
|
19 |
+
|
20 |
+
|
21 |
+
list_all_outputs function:
|
22 |
+
|
23 |
+
This function retrieves the list of all generated audio files from the specified directory (FILE_DIR_PATH).
|
24 |
+
It sorts the audio files based on their modification time in descending order, so the most recent files appear first.
|
25 |
+
It updates the generation_history by appending the new audio files to the existing history list.
|
26 |
+
It returns the updated generation_history and updates the visibility of the community list element.
|
27 |
+
|
28 |
+
|
29 |
+
show_output_list function:
|
30 |
+
|
31 |
+
This function is a rendering function that displays the community generations.
|
32 |
+
It takes the generation_history and list_size as inputs.
|
33 |
+
It retrieves the latest list_size number of audio files from the generation_history.
|
34 |
+
For each audio file, it reads the corresponding prompt from the associated text file.
|
35 |
+
It creates a group element for each audio file and displays the prompt as a markdown heading and the audio player.
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
Now, let's go through the relevant lines of code for saving and displaying the community history:
|
40 |
+
|
41 |
+
In the generate_audio function:
|
42 |
+
|
43 |
+
The code generates unique filenames for the audio file and the corresponding prompt text file using a random UUID.
|
44 |
+
It saves the generated audio using torchaudio.save(unique_filename, output, sample_rate).
|
45 |
+
It saves the prompt in a text file using with open(unique_textfile, "w") as file: file.write(prompt).
|
46 |
+
|
47 |
+
|
48 |
+
In the list_all_outputs function:
|
49 |
+
|
50 |
+
It retrieves the list of audio files from the specified directory using os.listdir(directory_path).
|
51 |
+
It filters the files to include only .wav files and sorts them based on modification time using wav_files.sort(key=lambda x: os.path.getmtime(os.path.join(directory_path, x)), reverse=True).
|
52 |
+
It updates the generation_history by appending the new audio files to the existing history list using updated_history = updated_files + history_list.
|
53 |
+
It returns the updated generation_history as a comma-separated string using ','.join(updated_history).
|
54 |
+
|
55 |
+
|
56 |
+
In the show_output_list function:
|
57 |
+
|
58 |
+
It retrieves the latest list_size number of audio files from the generation_history using history_list_latest = history_list[:list_size].
|
59 |
+
For each audio file, it constructs the corresponding prompt text file path using generation_prompt_file = generation.replace('.wav', '.txt').
|
60 |
+
It reads the prompt from the text file using with open(generation_prompt_file, 'r') as file: generation_prompt = file.read().
|
61 |
+
It creates a group element using with gr.Group(): and displays the prompt as a markdown heading using gr.Markdown(value=f"### {generation_prompt}") and the audio player using gr.Audio(value=generation).
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
The code uses the demo.load method to periodically call the list_all_outputs function every 2 seconds, which updates the generation_history and the community list element. This ensures that the history of saved audio files is continuously updated and displayed to everyone using the space. CopyRetryAWGenerate ten emojis to use for UI in this example which deals with sound audio recording and sound effects generation along with file save memory EditHere are ten emojis that could be used for the UI in this example, which deals with sound audio recording, sound effects generation, and file save memory:
|
66 |
+
|
67 |
+
🎙️ (Microphone): Represents audio recording or input.
|
68 |
+
🔊 (Speaker): Represents audio playback or output.
|
69 |
+
🎧 (Headphones): Represents listening to audio or using headphones.
|
70 |
+
🎼 (Musical Score): Represents music or sound composition.
|
71 |
+
🔍 (Magnifying Glass): Represents searching or exploring sound effects.
|
72 |
+
⚙️ (Gear): Represents settings or configuration options for audio generation.
|
73 |
+
💾 (Floppy Disk): Represents saving or storing audio files.
|
74 |
+
📂 (Folder): Represents the directory or location where audio files are saved.
|
75 |
+
⏱️ (Stopwatch): Represents the duration or timing of audio recordings.
|
76 |
+
🎛️ (Slider): Represents adjusting parameters or settings for sound effects generation.
|
77 |
+
|
78 |
+
These emojis can be used to enhance the visual representation and intuitive understanding of various elements and actions within the UI related to audio recording, sound effects generation, and file management.
|