Kim Adams commited on
Commit ·
f8b0a1a
1
Parent(s): 50c6548
prepping text for voice/dollars
Browse files- ai_voice/__pycache__/voice_handling.cpython-311.pyc +0 -0
- ai_voice/voice_handling.py +21 -5
- app.py +4 -3
- image_gen/__pycache__/image_creation.cpython-311.pyc +0 -0
- {ui → image_gen}/image_creation.py +7 -1
- prompts/__pycache__/prompt_builder.cpython-311.pyc +0 -0
- prompts/__pycache__/prompt_constants.cpython-311.pyc +0 -0
- {ui → prompts}/prompt_builder.py +6 -1
- prompts/prompt_constants.py +2 -2
- summarization/__pycache__/summarization.cpython-311.pyc +0 -0
- summarization/__pycache__/summarize.cpython-311.pyc +0 -0
- ui/summarization.py → summarization/summarize.py +6 -0
- utilities/__pycache__/clean_text.cpython-311.pyc +0 -0
- utilities/clean_text.py +4 -0
ai_voice/__pycache__/voice_handling.cpython-311.pyc
CHANGED
|
Binary files a/ai_voice/__pycache__/voice_handling.cpython-311.pyc and b/ai_voice/__pycache__/voice_handling.cpython-311.pyc differ
|
|
|
ai_voice/voice_handling.py
CHANGED
|
@@ -24,10 +24,27 @@ def SetVoiceId(newVoice):
|
|
| 24 |
print("SetVoiceId: voice_id: "+voice_id + " newVoice "+newVoice)
|
| 25 |
voice_id = GetVoiceId(newVoice)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
def PrepareForVoice(text):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
def GetVoiceId(voice):
|
| 33 |
if voice==constants.VOICE_2:
|
|
@@ -89,5 +106,4 @@ def TranslateAndProcessAudio(audio, prompt, eval_sentiment, eval_emotion, messag
|
|
| 89 |
processedAudio=PrepareForVoice(system_message)
|
| 90 |
audio_html=ProcessAudio(processedAudio)
|
| 91 |
df = pd.DataFrame(messages)
|
| 92 |
-
return messages, df, audio_html
|
| 93 |
-
|
|
|
|
| 24 |
print("SetVoiceId: voice_id: "+voice_id + " newVoice "+newVoice)
|
| 25 |
voice_id = GetVoiceId(newVoice)
|
| 26 |
|
| 27 |
+
def UpdateDF():
|
| 28 |
+
global dataframe
|
| 29 |
+
dataframe.value=pd.DataFrame({"role": [""], "content": [""] })
|
| 30 |
+
|
| 31 |
def PrepareForVoice(text):
|
| 32 |
+
print("prepped_text before: "+text)
|
| 33 |
+
p = inflect.engine()
|
| 34 |
+
prepped_text = text.replace('"', '').replace('401k', '4 oh 1 k').replace('slalom', "slallum").replace('Slalom', "slallum").replace('IT 101', "IT 1 oh 1")
|
| 35 |
+
prepped_text = re.sub(r'(\d+)m', lambda m: p.number_to_words(int(m.group(1)) * 1000000), prepped_text, flags=re.IGNORECASE)
|
| 36 |
+
prepped_text = re.sub(r'(\d+)k', lambda m: p.number_to_words(int(m.group(1)) * 1000), prepped_text, flags=re.IGNORECASE)
|
| 37 |
+
prepped_text = re.sub(r'\$(\d+(?:,\d{3})*(?:\.\d{2})?)', lambda m: p.number_to_words(int(m.group(1).replace(',', '')) if '.' not in m.group(1) else float(m.group(1).replace(',', ''))) + ' dollars', prepped_text, flags=re.IGNORECASE)
|
| 38 |
+
print("prepped_text: after "+prepped_text)
|
| 39 |
+
return clean_text.ReplaceNumbersWithWords(prepped_text) # Change to use ReplaceNumbersWithWords directly
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
'''def PrepareForVoice(text):
|
| 43 |
+
prepped_text = text.replace('"', '').replace(',', '').replace('401k', '4 oh 1 k').replace('10k', 'ten thousand').replace('slalom', "slallum").replace('Slalom', "slallum").replace('IT 101', "IT 1 oh 1")
|
| 44 |
+
print("prepped_text before: "+prepped_text)
|
| 45 |
+
prepped_text = re.sub(r'\$(\d+)', r'\1 dollars', prepped_text)
|
| 46 |
+
print("prepped_text: "+prepped_text)
|
| 47 |
+
return clean_text.ReplaceNumbersWithWords(prepped_text)'''
|
| 48 |
|
| 49 |
def GetVoiceId(voice):
|
| 50 |
if voice==constants.VOICE_2:
|
|
|
|
| 106 |
processedAudio=PrepareForVoice(system_message)
|
| 107 |
audio_html=ProcessAudio(processedAudio)
|
| 108 |
df = pd.DataFrame(messages)
|
| 109 |
+
return messages, df, audio_html
|
|
|
app.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import openai
|
|
|
|
|
|
|
| 4 |
from utilities import constants,api_keys
|
| 5 |
from ui.app_theme import SoftBlue
|
| 6 |
-
from
|
| 7 |
|
| 8 |
openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
|
| 9 |
|
| 10 |
-
|
| 11 |
ui1=prompt_builder.ui
|
| 12 |
-
ui2=
|
| 13 |
ui3=image_creation.ui
|
| 14 |
ui = gr.TabbedInterface([ui1,ui2,ui3], (constants.UI_1, constants.UI_2, constants.UI_3), theme=SoftBlue())
|
| 15 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import openai
|
| 4 |
+
from image_gen import image_creation
|
| 5 |
+
from summarization import summarize
|
| 6 |
from utilities import constants,api_keys
|
| 7 |
from ui.app_theme import SoftBlue
|
| 8 |
+
from prompts import prompt_builder
|
| 9 |
|
| 10 |
openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
|
| 11 |
|
|
|
|
| 12 |
ui1=prompt_builder.ui
|
| 13 |
+
ui2=summarize.ui
|
| 14 |
ui3=image_creation.ui
|
| 15 |
ui = gr.TabbedInterface([ui1,ui2,ui3], (constants.UI_1, constants.UI_2, constants.UI_3), theme=SoftBlue())
|
| 16 |
|
image_gen/__pycache__/image_creation.cpython-311.pyc
ADDED
|
Binary file (5.78 kB). View file
|
|
|
{ui → image_gen}/image_creation.py
RENAMED
|
@@ -5,6 +5,10 @@ from image_gen import image_generation
|
|
| 5 |
|
| 6 |
IMG_SIZE=256
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def UpdateArtSetting(setting):
|
| 9 |
global settingOptions
|
| 10 |
settingOptions.value=setting
|
|
@@ -49,4 +53,6 @@ with gr.Blocks() as ui:
|
|
| 49 |
imageDF = gr.DataFrame(type="pandas", value=pd.DataFrame({"role": [""], "content": [""] }), wrap=True, label=constants.OPENAI_LOG)
|
| 50 |
imageSubmit.click(Generate, inputs=[imageDescription], outputs=[image1,image2,image3,imageDF])
|
| 51 |
artOptions.input(UpdateArtStyle,inputs=[artOptions], outputs=[])
|
| 52 |
-
settingOptions.input(UpdateArtSetting,inputs=[settingOptions], outputs=[])
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
IMG_SIZE=256
|
| 7 |
|
| 8 |
+
def InitDF():
|
| 9 |
+
global imageDF
|
| 10 |
+
imageDF=pd.DataFrame({"role": [""], "content": [""] })
|
| 11 |
+
|
| 12 |
def UpdateArtSetting(setting):
|
| 13 |
global settingOptions
|
| 14 |
settingOptions.value=setting
|
|
|
|
| 53 |
imageDF = gr.DataFrame(type="pandas", value=pd.DataFrame({"role": [""], "content": [""] }), wrap=True, label=constants.OPENAI_LOG)
|
| 54 |
imageSubmit.click(Generate, inputs=[imageDescription], outputs=[image1,image2,image3,imageDF])
|
| 55 |
artOptions.input(UpdateArtStyle,inputs=[artOptions], outputs=[])
|
| 56 |
+
settingOptions.input(UpdateArtSetting,inputs=[settingOptions], outputs=[])
|
| 57 |
+
|
| 58 |
+
InitDF()
|
prompts/__pycache__/prompt_builder.cpython-311.pyc
ADDED
|
Binary file (7.82 kB). View file
|
|
|
prompts/__pycache__/prompt_constants.cpython-311.pyc
CHANGED
|
Binary files a/prompts/__pycache__/prompt_constants.cpython-311.pyc and b/prompts/__pycache__/prompt_constants.cpython-311.pyc differ
|
|
|
{ui → prompts}/prompt_builder.py
RENAMED
|
@@ -13,6 +13,10 @@ def UpdatePersonas(person_new):
|
|
| 13 |
label, messages, persona.value = system_prompts.ChangePersona(person_new,[],persona)
|
| 14 |
return label
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def Clear():
|
| 17 |
global audio
|
| 18 |
audio.value=None
|
|
@@ -87,4 +91,5 @@ with gr.Blocks() as ui:
|
|
| 87 |
sentiment.change(ToggleSentiment, inputs=[sentiment], outputs=[])
|
| 88 |
emotion.change(ToggleEmotion, inputs=[emotion], outputs=[])
|
| 89 |
|
| 90 |
-
UpdatePersonas(constants.PERSONA_HR_EXPERT)
|
|
|
|
|
|
| 13 |
label, messages, persona.value = system_prompts.ChangePersona(person_new,[],persona)
|
| 14 |
return label
|
| 15 |
|
| 16 |
+
def InitDF():
|
| 17 |
+
global dataframe
|
| 18 |
+
dataframe=pd.DataFrame({"role": [""], "content": [""] })
|
| 19 |
+
|
| 20 |
def Clear():
|
| 21 |
global audio
|
| 22 |
audio.value=None
|
|
|
|
| 91 |
sentiment.change(ToggleSentiment, inputs=[sentiment], outputs=[])
|
| 92 |
emotion.change(ToggleEmotion, inputs=[emotion], outputs=[])
|
| 93 |
|
| 94 |
+
UpdatePersonas(constants.PERSONA_HR_EXPERT)
|
| 95 |
+
InitDF()
|
prompts/prompt_constants.py
CHANGED
|
@@ -8,8 +8,8 @@ SPANISH_PROMPT="Provide responses entirely in Spanish."
|
|
| 8 |
FRENCH_PROMPT="Provide responses entirely in French."
|
| 9 |
ENGLISH_PROMPT="Provide responses entirely in English."
|
| 10 |
SUMMARY_PROMPT="Identify the language (code) or genre (literature) as Type, summarize what this text does as simply as possible in the Summary. Identify key areas of interest in Key Concepts. Format response as follows:\nType: Python\nSummary: The code performs web scraping, text processing, tokenization, embedding generation, and question-answering tasks using OpenAI models and libraries.\nKey Concepts: Key concepts include the web scraping logic, text processing techniques, and the usage of OpenAI's embedding and question-answering models. Content: "
|
| 11 |
-
SENTIMENT_PROMPT="At the end of the response, Provide a sentiment evaluation of the user's input as \nSentiment: [Positive, Neutral, Negative]."
|
| 12 |
-
EMOTION_PROMPT = "At the end of the response, Provide an emotion evaluation of the user's input as \nEmotion: [Happy, Angry, Sad, etc]."
|
| 13 |
IMPRESSIONISM_PROMPT="Impressionist Art. Use short, thick strokes of paint to capture the essence of the Subject rather than the details. Focus on the changing effects of light on the subject. Ex. Monet"
|
| 14 |
POP_ART_PROMPT="Pop Art. Use bold, vibrant colors and iconic imagery to capture the spirit of the Subject, including consumerism, mass media, and popular culture. Ex. Warhol"
|
| 15 |
CUBISM_PROMPT="Cubist Art. Fragment and reassemble the Subject into an abstracted form, focus on geometric shapes and multiple viewpoints to depict the subject across dimensions. Ex.Picasso."
|
|
|
|
| 8 |
FRENCH_PROMPT="Provide responses entirely in French."
|
| 9 |
ENGLISH_PROMPT="Provide responses entirely in English."
|
| 10 |
SUMMARY_PROMPT="Identify the language (code) or genre (literature) as Type, summarize what this text does as simply as possible in the Summary. Identify key areas of interest in Key Concepts. Format response as follows:\nType: Python\nSummary: The code performs web scraping, text processing, tokenization, embedding generation, and question-answering tasks using OpenAI models and libraries.\nKey Concepts: Key concepts include the web scraping logic, text processing techniques, and the usage of OpenAI's embedding and question-answering models. Content: "
|
| 11 |
+
SENTIMENT_PROMPT="At the end of the response, Provide a sentiment evaluation of the user's input as \nSentiment: [Positive, Neutral, Negative]. Include '.' at the end of the sentence."
|
| 12 |
+
EMOTION_PROMPT = "At the end of the response, Provide an emotion evaluation of the user's input as \nEmotion: [Happy, Angry, Sad, etc]. Include '.' at the end of the sentence."
|
| 13 |
IMPRESSIONISM_PROMPT="Impressionist Art. Use short, thick strokes of paint to capture the essence of the Subject rather than the details. Focus on the changing effects of light on the subject. Ex. Monet"
|
| 14 |
POP_ART_PROMPT="Pop Art. Use bold, vibrant colors and iconic imagery to capture the spirit of the Subject, including consumerism, mass media, and popular culture. Ex. Warhol"
|
| 15 |
CUBISM_PROMPT="Cubist Art. Fragment and reassemble the Subject into an abstracted form, focus on geometric shapes and multiple viewpoints to depict the subject across dimensions. Ex.Picasso."
|
summarization/__pycache__/summarization.cpython-311.pyc
CHANGED
|
Binary files a/summarization/__pycache__/summarization.cpython-311.pyc and b/summarization/__pycache__/summarization.cpython-311.pyc differ
|
|
|
summarization/__pycache__/summarize.cpython-311.pyc
ADDED
|
Binary file (6 kB). View file
|
|
|
ui/summarization.py → summarization/summarize.py
RENAMED
|
@@ -11,6 +11,10 @@ def Summary(code):
|
|
| 11 |
df = pd.DataFrame(sum_messages)
|
| 12 |
return sum_text,df
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def UpdateWithExample(newExample):
|
| 15 |
fileName=newExample.replace(" ","_").lower()
|
| 16 |
if os.path.exists(f"{constants.TXT_PREFIX}{fileName}.txt"):
|
|
@@ -46,3 +50,5 @@ with gr.Blocks() as ui:
|
|
| 46 |
wrap=True, show_label=False, label=constants.OPENAI_LOG)
|
| 47 |
summarize.click(Summary, inputs=[code], outputs=[summary,summaryDF])
|
| 48 |
examples.input(UpdateWithExample,inputs=[examples], outputs=[code])
|
|
|
|
|
|
|
|
|
| 11 |
df = pd.DataFrame(sum_messages)
|
| 12 |
return sum_text,df
|
| 13 |
|
| 14 |
+
def InitDF():
|
| 15 |
+
global summaryDF
|
| 16 |
+
summaryDF=pd.DataFrame({"role": [""], "content": [""] })
|
| 17 |
+
|
| 18 |
def UpdateWithExample(newExample):
|
| 19 |
fileName=newExample.replace(" ","_").lower()
|
| 20 |
if os.path.exists(f"{constants.TXT_PREFIX}{fileName}.txt"):
|
|
|
|
| 50 |
wrap=True, show_label=False, label=constants.OPENAI_LOG)
|
| 51 |
summarize.click(Summary, inputs=[code], outputs=[summary,summaryDF])
|
| 52 |
examples.input(UpdateWithExample,inputs=[examples], outputs=[code])
|
| 53 |
+
|
| 54 |
+
InitDF()
|
utilities/__pycache__/clean_text.cpython-311.pyc
CHANGED
|
Binary files a/utilities/__pycache__/clean_text.cpython-311.pyc and b/utilities/__pycache__/clean_text.cpython-311.pyc differ
|
|
|
utilities/clean_text.py
CHANGED
|
@@ -7,10 +7,14 @@ def RemoveRole(text):
|
|
| 7 |
def ReplaceNumbersWithWords(text):
|
| 8 |
p = inflect.engine()
|
| 9 |
words = text.split()
|
|
|
|
| 10 |
for i, word in enumerate(words):
|
| 11 |
if word.isdigit():
|
|
|
|
| 12 |
words[i] = p.number_to_words(word)
|
| 13 |
elif word in constants.SYMBOL_TO_WORD:
|
|
|
|
| 14 |
words[i] = constants.SYMBOL_TO_WORD[word]
|
| 15 |
reply=' '.join(words)
|
|
|
|
| 16 |
return reply
|
|
|
|
| 7 |
def ReplaceNumbersWithWords(text):
|
| 8 |
p = inflect.engine()
|
| 9 |
words = text.split()
|
| 10 |
+
print("words: "+str(words))
|
| 11 |
for i, word in enumerate(words):
|
| 12 |
if word.isdigit():
|
| 13 |
+
print("word-isdigit: "+word)
|
| 14 |
words[i] = p.number_to_words(word)
|
| 15 |
elif word in constants.SYMBOL_TO_WORD:
|
| 16 |
+
print("word - else: "+word+" symbol: "+constants.SYMBOL_TO_WORD[word])
|
| 17 |
words[i] = constants.SYMBOL_TO_WORD[word]
|
| 18 |
reply=' '.join(words)
|
| 19 |
+
print('returning: '+reply)
|
| 20 |
return reply
|