Bils commited on
Commit
186d50e
β€’
1 Parent(s): 6bbcd0d

Upload 4 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Bilsimaging_radio_imaging_output.wav filter=lfs diff=lfs merge=lfs -text
Bilsimaging_radio_imaging_output.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fc5595853421474e59ad9c06d2071e37bb91cf58a9c21fddcddeb2d3a6e2f04
3
+ size 1303098
README.md CHANGED
@@ -1,13 +1,60 @@
1
- ---
2
- title: Radio Imaging Audio Generator
3
- emoji: πŸ“š
4
- colorFrom: yellow
5
- colorTo: indigo
6
- sdk: streamlit
7
- sdk_version: 1.28.2
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # 🌟Radio Imaging Audio Generator
3
+
4
+ ## πŸ“œDescription
5
+ The Radio Imaging Audio Generator is a Streamlit-based application designed for radio producers and music creators. It combines OpenAI's GPT models with Facebook's MusicGen technology, enabling the generation of unique audio pieces from user-provided prompts.
6
+
7
+ ## πŸš€ Features
8
+ - Text-prompt-based audio generation for radio imaging.
9
+ - Integration with OpenAI's GPT and Facebook's MusicGen models.
10
+ - User-friendly interface for inputting prompts and API keys.
11
+ - Direct audio playback and download options within the app.
12
+
13
+ ### 🌐 Project Continuation and User Involvement
14
+ This app is the next step in our project, following the Custom GPT Radio Imaging and MusicGen AI. It's tailored for radio producers and music creators, offering new levels of creativity and efficiency.
15
+ [GPT] (https://chat.openai.com/g/g-65x53n87E-radio-imaging-musicgen-ai)
16
+
17
+ #### πŸ‘₯ How You Can Contribute
18
+ - **Feedback**: Share your experiences and improvement suggestions.
19
+ - **Use Cases**: Tell us about your process using the app.
20
+ - **Spread the Word**: Help others discover and use this tool.
21
+
22
+ ## πŸ›  Installation
23
+
24
+ ### Requirements
25
+ - Python 3.x
26
+ - Streamlit
27
+ - Transformers
28
+ - SciPy
29
+ - TensorFlow
30
+ - PyTorch
31
+ - OpenAI API key
32
+
33
+ ### Setup
34
+ 1. Clone the repository.
35
+ 2. Install required packages: `pip install -r requirements.txt`
36
+ 3. Run the app: `streamlit run app.py`
37
+
38
+ ## Usage
39
+ 1. Launch the Streamlit app.
40
+ 2. Enter your OpenAI API key.
41
+ 3. Select an OpenAI chat model.
42
+ 4. Input a description for the audio piece.
43
+ 5. Click 'Generate Audio'.
44
+ 6. Listen and download the audio directly in the app.
45
+
46
+ ### 🌐 Access the Application
47
+ Experience the Radio Imaging Audio Generator now: Access the Streamlit App here.
48
+
49
+ ### πŸ’– Support
50
+ To support further development, consider donating at [Ko-fi](https://ko-fi.com/bilsimaging).
51
+
52
+ Thank you for your interest!
53
+ - Bilel Aroua
54
+
55
+ ### License
56
+ [MIT License](LICENSE)
57
+
58
+ ### πŸ’¬ Contact
59
+ Email: [contact@bilsimaging.com](mailto:contact@bilsimaging.com)
60
+ More Info: [Bilsimaging](https://bilsimaging.com)
radio_imaging_app.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoProcessor, MusicgenForConditionalGeneration
3
+ import scipy.io.wavfile
4
+ import openai
5
+ import time # Used for simulating progress
6
+ import torch
7
+ import tensorflow as tf
8
+
9
+
10
+ # Streamlit app setup
11
+ st.set_page_config(
12
+ page_icon="https://soundboard.bilsimaging.com/faviconbilsimaging.png",
13
+ layout="wide",
14
+ page_title='Radio Imaging Audio Generator Beta 0.1',
15
+ initial_sidebar_state="expanded"
16
+ )
17
+
18
+ # Main Description and Header
19
+ st.markdown("""
20
+ <h1 style=''>Radio Imaging Audio Generator
21
+ <span style='font-size: 24px; color: #FDC74A;'>Beta 0.1</span></h1>
22
+ """, unsafe_allow_html=True)
23
+ st.write("Welcome to the Radio Imaging & MusicGen Ai audio generator. This web application allows you to easily create unique audio for your radio imaging projects or any music creators using AI technology.")
24
+ st.markdown("---")
25
+
26
+ # How to Use the App - Instructions
27
+ with st.expander('πŸ“˜ How to Use This Web App?'):
28
+ st.markdown('''
29
+ To get started with creating your unique audio pieces, follow these simple steps:
30
+
31
+ **1. Enter OpenAI API Key**
32
+ - In the sidebar, input your **OpenAI API key**. This is essential to access the GPT model for generating audio descriptions.
33
+ - Don't have an API key? Get one for free [here](https://platform.openai.com/account/api-keys).
34
+
35
+ **2. Select GPT Model**
36
+ - Choose the desired GPT model from the dropdown in the sidebar. We recommend using **'gpt-3.5-turbo-16k'** for more detailed and rich descriptions.
37
+
38
+ **3. Input Your Detailed Description**
39
+ - Describe your audio idea in the text area provided. Be as detailed as possible to guide the AI effectively. This could include the mood, style, specific instruments, or any other relevant details.
40
+
41
+ **4. Generate and Review the Prompt**
42
+ - Click on **'πŸ“„ Generate Prompt'** to create a descriptive prompt for your audio. Review it to ensure it aligns with your vision.
43
+
44
+ **5. Generate Your Audio**
45
+ - If you're satisfied with the prompt, hit **'β–Ά Generate Audio'**. This will process your request and create the audio piece based on the AI-generated description.
46
+
47
+ **6. Playback and Download**
48
+ - Once generated, you can play the audio directly within the app. If it meets your needs, feel free to download and use it in your projects.
49
+ ''')
50
+
51
+
52
+ # Sidebar for user inputs
53
+ with st.sidebar:
54
+ openai_api_key = st.text_input("OpenAI API key", type="password", help="Enter your OpenAI API key here.")
55
+ st.caption("*If you don't have an OpenAI API key, get it [here](https://platform.openai.com/account/api-keys).*")
56
+ model = st.selectbox("OpenAI chat model", ("gpt-3.5-turbo", "gpt-3.5-turbo-16k"), help="Select the desired GPT model.")
57
+ st.markdown("Check out our video tutorials on [YouTube](https://www.youtube.com/channel/UCdDH7T3oa8YMPFV5e79skaA) for helpful guides on using this app!")
58
+ st.markdown('''Made with ❀️ by [Bilsimaging](https://bilsimaging.com)''', unsafe_allow_html=True)
59
+
60
+ # Guidelines for generating prompt and audio
61
+ st.markdown("""
62
+ ### πŸ’‘ Steps to Generate Your Audio:
63
+ 1. **Write your Detailed Description**
64
+ 2. **Generate Prompt**: Click 'Generate Prompt' to create a description for your radio imaging audio.
65
+ 3. **Review the Prompt**: Read the output and make sure it aligns with what you have in mind.
66
+ 4. **Generate Audio**: If you are satisfied with the prompt, click 'Generate Audio' to create your audio piece.
67
+ """)
68
+
69
+ # Prompt input
70
+ st.markdown("## ✍🏻Write your Description")
71
+ prompt = st.text_area("Enter your radio imaging draft idea prompt here", help="Describe the audio piece you want to create.")
72
+
73
+ # Instructions for users
74
+ st.info("πŸ‘‰πŸ» Provide a detailed description of the audio you need, such as mood, instruments, and style. Example: A calm, soothing melody with soft piano for a morning show.")
75
+
76
+ # Generate Prompt Button with user confirmation and patience message
77
+ st.markdown("## πŸ“ Generate Prompt")
78
+ st.info("🚨 Generating the prompt may take a few moments. Please be patient.")
79
+ if st.button("πŸ“„ Generate Prompt"):
80
+ if not openai_api_key.strip() or not prompt.strip():
81
+ st.error("Please provide both the OpenAI API key and a description for your radio imaging.")
82
+ else:
83
+ with st.spinner("Generating your prompt... Please wait, this might take a few moments."):
84
+ try:
85
+ full_prompt = {"role": "user", "content": f"Describe a radio imaging audio piece based on: {prompt}"}
86
+ response = openai.ChatCompletion.create(model=model, messages=[full_prompt], api_key=openai_api_key)
87
+ descriptive_text = response.choices[0].message['content'].strip()
88
+
89
+ # Append a copyright notice or tag
90
+ copyright_notice = "\n\nΒ© Created through Radio Imaging Audio Generator by Bilsimaging [WEBSITE](https://bilsimaging.com)"
91
+ descriptive_text += copyright_notice
92
+
93
+ st.session_state['generated_prompt'] = descriptive_text
94
+ st.success("Your prompt has been successfully generated! Review the prompt below:")
95
+ st.write(descriptive_text)
96
+
97
+ # Download Button for the generated prompt
98
+ st.download_button(
99
+ label="Download Prompt",
100
+ data=descriptive_text,
101
+ file_name="generated_prompt.txt",
102
+ mime="text/plain"
103
+ )
104
+
105
+ except Exception as e:
106
+ st.error(f"An error occurred: {e}")
107
+
108
+ st.markdown("---")
109
+
110
+ # ... [Earlier parts of the script remain unchanged]
111
+
112
+ # Generate Audio Button with Progress Bar and Load Management
113
+ st.markdown("## 🎢 Generate Audio")
114
+ st.info("🚨 Please be patient as generating audio can take some time. This might take a moment due to resource limits. Feel free to notify me if you encounter any issues.")
115
+
116
+ if st.button("β–Ά Generate Audio"):
117
+ if 'generated_prompt' not in st.session_state or not st.session_state['generated_prompt']:
118
+ st.error("Please generate and approve a prompt before creating audio.")
119
+ else:
120
+ descriptive_text = st.session_state['generated_prompt']
121
+
122
+ # Placeholder for server load check
123
+ server_ready_for_audio_generation = True # Replace with actual server load check logic
124
+
125
+ if server_ready_for_audio_generation:
126
+ with st.spinner("Generating your audio... Please wait, this might take a few moments."):
127
+ progress_bar = st.progress(0)
128
+ for i in range(100):
129
+ time.sleep(0.1) # Simulate processing
130
+ progress_bar.progress(i + 1)
131
+
132
+ try:
133
+ processor = AutoProcessor.from_pretrained("facebook/musicgen-small")
134
+ musicgen_model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-small")
135
+ inputs = processor(text=[descriptive_text], padding=True, return_tensors="pt")
136
+ audio_values = musicgen_model.generate(**inputs, max_new_tokens=512)
137
+ sampling_rate = musicgen_model.config.audio_encoder.sampling_rate
138
+
139
+ audio_filename = "Bilsimaging_radio_imaging_output.wav"
140
+ scipy.io.wavfile.write(audio_filename, rate=sampling_rate, data=audio_values[0, 0].numpy())
141
+ st.success("Your audio has been successfully created! Below is a description of your audio piece based on the GPT model's understanding:")
142
+ st.write(descriptive_text)
143
+ st.audio(audio_filename)
144
+ except Exception as e:
145
+ st.error(f"An error occurred: {e}")
146
+ finally:
147
+ progress_bar.empty() # Remove the progress bar after completion
148
+ else:
149
+ st.warning("The server is currently busy. Please try generating your audio again later.")
150
+
151
+ # ... [Rest of the code remains the same]
152
+
153
+ # Footer and Support Section
154
+ st.markdown("---")
155
+ st.markdown("## 🌐 Project Continuation and User Involvement")
156
+ st.markdown("βœ”οΈ This app is the next step in our project, following the Custom GPTs Radio Imaging and MusicGen AI. <br>It's tailored for radio producers and music creators, offering new levels of creativity and efficiency by Bilsimaging. [Try our GPTs](https://chat.openai.com/g/g-65x53n87E-radio-imaging-musicgen-ai).", unsafe_allow_html=True)
157
+ st.markdown("If you appreciate my deployment and wish to support me, please consider a donation. Your support helps me continue providing value. Thank you for joining me on this journey! - Bilel Aroua")
158
+ st.markdown("For support β˜• [Buy me a Coffee](https://ko-fi.com/bilsimaging).")
159
+ st.image('https://storage.ko-fi.com/cdn/brandasset/kofi_button_dark.png', width=300, caption="Project Bilsimaigng")
160
+
161
+ # Hide Streamlit branding
162
+ st.markdown("<style>#MainMenu {visibility: hidden;} footer {visibility: hidden;}</style>", unsafe_allow_html=True)
requirements.txt ADDED
Binary file (226 Bytes). View file