# from gpt_module import generate_response # from dalle_module import generate_image # from translation_module import translation_to_english # from tts_module import text_to_speech # from stt import transcribe_audio # def main(): # print("Welcome to the ChatGPT CLI application!") # while True: # user_input = input("Enter command: ") # if user_input.startswith('/imagine'): # img = user_input.replace('/imagine', '').strip() # print(generate_image(img)) # elif user_input.startswith('/chat'): # prompt = user_input.replace('/chat', '').strip() # print(generate_response(prompt)) # elif user_input.startswith('/translate'): # tra = user_input.replace('/translate', '').strip() # print(translation_to_english(tra)) # elif user_input.startswith('/voice'): # text = user_input.replace('/voice', '').strip() # print(text_to_speech(text)) # elif user_input.startswith('/transcribe'): # print("Please upload the audio file.") # audio_file = input("Enter the path to the audio file: ") # print(transcribe_audio(audio_file)) # elif user_input.startswith('/help'): # print_help() # else: # print("Unknown command. Type '/help' for a list of commands.") # def print_help(): # help_text = """ # 👉 To generate an image, type '/imagine ' # 👉 To chat with the model, type '/chat ' # 👉 To translate text to English, type '/translate ' # 👉 For Text to Speech, type '/voice ' # 👉 To transcribe audio to text, type '/transcribe' and follow the prompts # 👉 For help, type '/help' # """ # print(help_text) # if __name__ == '__main__': # main() import streamlit as st from gpt_module import generate_response from dalle_module import generate_image from translation_module import translation_to_english from tts_module import text_to_speech from stt import transcribe_audio import os def main(): st.sidebar.title("Hey Rehan Assistant") user_input = st.sidebar.selectbox("Select command:", ["/imagine", "/chat", "/translate", "/voice", "/transcribe", "/help"]) if user_input == "/imagine": st.subheader('Prompt To Image generation', divider='rainbow') prompt = st.text_input("Enter prompt To Generate Image:") if st.button("Generate Image"): st.image(generate_image(prompt)) elif user_input == "/chat": st.subheader('Hey Rehan AI Assistant', divider='rainbow') prompt = st.text_input("Ask anything You want to know") if st.button("Chat"): response = generate_response(prompt) st.success(response) elif user_input == "/translate": st.subheader('Translate Into English', divider='rainbow') audio_file = st.file_uploader("Upload Audio File", type=["mp3", "wav"]) if audio_file is not None: # st.audio(uploaded_file, format='audio/wav') if st.button("Translate to English"): result = translation_to_english(audio_file) st.success(result) elif user_input == "/voice": st.subheader('Text to Speech', divider='rainbow') text = st.text_input("Enter text for Text to Speech:") if st.button("Convert to Speech"): audio_bytes = text_to_speech(text) st.audio(audio_bytes, format='audio/wav') elif user_input == "/transcribe": st.subheader('Audio to Text Transcription', divider='rainbow') uploaded_file = st.file_uploader("Upload audio file", type=["mp3", "wav"]) if uploaded_file is not None: if st.button("Transcribe Audio"): with open("temp_audio_file.mp3", "wb") as f: f.write(uploaded_file.getvalue()) transcription = transcribe_audio("temp_audio_file.mp3") st.success(transcription) os.remove("temp_audio_file.mp3") elif user_input == "/help": print_help() def print_help(): help_text = """ 👉 To generate an image, select '/imagine' and enter a prompt. 👉 To chat with the model, select '/chat' and enter a prompt. 👉 To translate text to English, select '/translate' and enter text. 👉 For Text to Speech, select '/voice' and enter some text. 👉 To transcribe audio to text, select '/transcribe' and upload the audio file. 👉 For help, select '/help'. """ st.write(help_text) if __name__ == '__main__': main()