Spaces:
Sleeping
Sleeping
File size: 4,681 Bytes
6cc9795 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# 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 <prompt>'
# π To chat with the model, type '/chat <prompt>'
# π To translate text to English, type '/translate <text>'
# π For Text to Speech, type '/voice <some text>'
# π 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()
|