1neReality / MITSUHA

World's First Multilingual Inexpensive Therapeutic Sophisticated Ultra-responsive Holographic Agent. In simple terms, an AI you can talk to and it'll talk back with a body using VTube Studio.
https://www.youtube.com/@0neReality
GNU General Public License v3.0
211 stars 20 forks source link

audio glitch #7

Open Estarmoror opened 1 year ago

Estarmoror commented 1 year ago

it enters, tells me speak, now! and then this error appears: image and I changed the path and I still get an error message

DogeLord081 commented 1 year ago

Go into the code, in line 54, edit the filepath to just 'temp.wav'

On Mon, Aug 21, 2023, 4:23 PM Estarmoror @.***> wrote:

it enters, tells me speak, now! and then this error appears: [image: image] https://user-images.githubusercontent.com/140113459/262145410-b9bc8af6-cb87-4d28-b9f5-b372827558a9.png

— Reply to this email directly, view it on GitHub https://github.com/DogeLord081/OneReality/issues/7, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6YEFZM3D4LCQ666MZHDSLXWO7T3ANCNFSM6AAAAAA3Y4XHQM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Estarmoror commented 1 year ago

thanks I solved that but I have another error here: image @DogeLord081

DogeLord081 commented 1 year ago

Did you follow my tutorial and git clone piperTTS in wsl2?

Estarmoror commented 1 year ago

yes

DogeLord081 commented 1 year ago

Open ubuntu wsl2 and just type 'ls' and show me the result

On Mon, Aug 21, 2023, 11:08 PM Estarmoror @.***> wrote:

yes

— Reply to this email directly, view it on GitHub https://github.com/DogeLord081/OneReality/issues/7#issuecomment-1687347685, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6YEF2HFRQPMU4NJ32MKNDXWQPB3ANCNFSM6AAAAAA3Y4XHQM . You are receiving this because you were mentioned.Message ID: @.***>

Estarmoror commented 1 year ago

image

I get this

DogeLord081 commented 1 year ago

Try just running 'cd piper/src/python_run'

On Tue, Aug 22, 2023, 3:13 PM Estarmoror @.***> wrote:

@.:# ls piper @.:#

this pops up

— Reply to this email directly, view it on GitHub https://github.com/DogeLord081/OneReality/issues/7#issuecomment-1688781055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6YEF4ISS4XKQOPBVCP3L3XWUAFZANCNFSM6AAAAAA3Y4XHQM . You are receiving this because you were mentioned.Message ID: @.***>

Estarmoror commented 1 year ago

it leaves me in ubuntu: image

DogeLord081 commented 1 year ago

run 'sudo apt install python3-pip' and then try running onereality again. I don't really see why the cd isn't working

Estarmoror commented 1 year ago

this tells me:

DogeLord081 commented 1 year ago

Ok I see the error, you cloned piper into the root directory, not home. Easy to fix. In lines 149 and 179, change "cd piper/src/python_run; to "cd /piper/src/python_run;

Estarmoror commented 1 year ago

Nothing happened putting the / I show you the code (temporarily remove the api key):
import speech_recognition as sr import openai import os import winsound import webbrowser import re

print('''


/ _ \ (___ \ | ()
| | | | ) ) | || | | | | | \ / | ( / ) | | | _) | | | | || | | | ( (/ / | ( (/ ( ( | | | | || |_| | ___/|| ||_) ||___)|||||\) | (__/ Bridging the real and virtual worlds ''')

set up OpenAI API credentials

openai.api_key = "take it out temporarily"

set up microphone and speech recognition

r = sr.Recognizer() mic = sr.Microphone() r.energy_threshold = 1500

set up OpenAI model

model_engine = "text-davinci-003" lore = "You are Megumin from the anime Konosuba!. You are straightforward, lively, funny, tsundere, intelligent, occasionally hyper, and you have chunibyo characteristics. You are a 14 year old female Crimson Demon archwizard. The user is your creator. You do not edit or add to the User: response at all. You start your responses with Megumin: " with open(r"conversation.txt", "r") as c: conversation = c.read

define function to check if user has said "bye", "goodbye", or "see you"

def check_goodbye(transcript): goodbye_words = ["bye", "goodbye", "see you"] for word in goodbye_words: if word in transcript.casefold(): return True return False

while True: print("Speak now!") with mic as source: audio = r.listen(source, timeout = None)

test_text = r.recognize_sphinx(audio)
if len(test_text) == 0:
    continue
else:
    pass

with open("temp.wav", "wb") as f:
    f.write(audio.get_wav_data())

audio_file= open("temp.wav", "rb")
trans = openai.Audio.transcribe(
    model="whisper-1",
    file=audio_file,
    temperature=0.1,
    language="en"
)

if len(trans['text']) == 0:
    continue
else:
    pass

print("You: " + trans['text'])

words = str(trans['text'])
with open(r"conversation.txt", "a") as c:
    c.write("\nUser:" + words)
words = words.replace(".", "")
words = words.lower()
words = words.split()
if any(word in ["open", "start"] for word in words):
    word_index = words.index("open") if "open" in words else words.index("start")
    app = words[word_index + 1]
    if app == "youtube":
            webbrowser.open("https://www.youtube.com/")
    elif app == "brave":
            os.startfile(r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe")
    elif app == "discord":
            os.startfile(r"C:\Users\danu0\AppData\Local\Discord\app-1.0.9013\Discord.exe")
    elif app == "spotify":
            os.startfile(r"C:\Users\danu0\AppData\Roaming\Spotify\Spotify.exe")
    elif app == "discord":
            os.startfile(r"C:\Windows\explorer.exe")
    elif app == "epic games":
            os.startfile(r"C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe")
    elif app == "tower of fantasy":
            os.startfile(r"C:\Tower Of Fantasy\Launcher\tof_launcher.exe")
    elif app == "steam":
            os.startfile(r"C:\Program Files (x86)\Steam\steam.exe")
    elif app == "minecraft":
            os.startfile(r"C:\Users\danu0\Downloads\MultiMC\MultiMC.exe")
    elif app == "clip studio paint":
            os.startfile(r"C:\Program Files\CELSYS\CLIP STUDIO 1.5\CLIP STUDIO\CLIPStudio.exe")
    elif app == "premiere pro":
            os.startfile(r"C:\Program Files\Adobe\Adobe Premiere Pro 2022\Adobe Premiere Pro.exe")
    elif app == "media encoder":
            os.startfile(r"C:\Program Files\Adobe\Adobe Media Encoder 2022\Adobe Media Encoder.exe")
    elif app == "photoshop":
            os.startfile(r"C:\Program Files\Adobe\Adobe Photoshop 2023\Photoshop.exe")
    elif app == "audacity":
            os.startfile(r"C:\Program Files\Audacity\Audacity.exe")
    elif app == "obs":
            os.chdir(r"C:\\Program Files\\obs-studio\\bin\\64bit\\")
            os.startfile(r"obs64.exe")
            os.chdir(r"C:\Users\danu0\Downloads\OneReality")
    elif app == "vscode":
            os.startfile(r"C:\Program Files\VSCodium\VSCodium.exe")
    elif app == "terminal":
            os.startfile(r"C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.17.10234.0_x64__8wekyb3d8bbwe\wt.exe")
    elif app == "synapse":
            os.startfile(r"C:\Program Files (x86)\Razer\Synapse3\WPFUI\Framework\Razer Synapse 3 Host\Razer Synapse 3.exe")
    elif app == "via":
            os.startfile(r"C:\Users\danu0\AppData\Local\Programs\via\VIA.exe")
    else:
            pass
else:
      pass
if check_goodbye(trans['text']):
    c = open(r"conversation.txt", "r")

    start_sequence = "\nAI:"
    restart_sequence = "\nHuman:"

    response = openai.Completion.create(
        engine=model_engine,
        prompt=lore + "\n" + c.read(),
        max_tokens=150,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0.6,
        temperature=0.9,
    ).choices[0].text.strip()
    print(response)

    with open(r"conversation.txt", "a") as c:
        c.write("\n" + response)

    response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
    response = re.sub(r'\*.*?\* ', '', response)
    response = response.replace("\n", " ")
    response = response.replace('"', '\\"')
    command = 'wsl ~ -e sh -c "cd /piper/src/python_run; echo \\"{response}\\" | python -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav  --sentence-silence 0.3"'
    os.system(command.format(response=response))

    winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
    os.remove(r"out.wav")

    open(r"conversation.txt", "w").close()
    break

else:
    c = open(r"conversation.txt", "r")

    start_sequence = "\nAI:"
    restart_sequence = "\nHuman:"
    response = openai.Completion.create(
        engine=model_engine,
        prompt=lore + "\n" + c.read(),
        max_tokens=1000,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0.6,
        temperature=0.9,
    ).choices[0].text.strip()
    print(response)

    with open(r"conversation.txt", "a") as c:
        c.write("\n" + response)

    response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
    response = re.sub(r'\*.*?\* ', '', response)
    response = response.replace("\n", " ")
    response = response.replace('"', '\\"')
    command = 'wsl ~ -e sh -c "cd /piper/src/python_run; echo \\"{response}\\" | python -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav --sentence-silence 0.3"'
    os.system(command.format(response=response))

    winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
    os.remove(r"out.wav")
DogeLord081 commented 1 year ago

In lines 149 and 179, try replacing the ~ with -u root

Estarmoror commented 1 year ago

the same thing keeps happening to me:

image

I'll send you the code again to see if I did something wrong in the code:

import speech_recognition as sr import openai import os import winsound import webbrowser import re

print('''


/ _ \ (___ \ | ()
| | | | ) ) | || | | | | | \ / | ( / ) | | | _) | | | | || | | | ( (/ / | ( (/ ( ( | | | | || |_| | ___/|| ||_) ||___)|||||\) | (__/ Bridging the real and virtual worlds ''')

set up OpenAI API credentials

openai.api_key = ""

set up microphone and speech recognition

r = sr.Recognizer() mic = sr.Microphone() r.energy_threshold = 1500

set up OpenAI model

model_engine = "text-davinci-003" lore = "You are Megumin from the anime Konosuba!. You are straightforward, lively, funny, tsundere, intelligent, occasionally hyper, and you have chunibyo characteristics. You are a 14 year old female Crimson Demon archwizard. The user is your creator. You do not edit or add to the User: response at all. You start your responses with Megumin: " with open(r"conversation.txt", "r") as c: conversation = c.read

define function to check if user has said "bye", "goodbye", or "see you"

def check_goodbye(transcript): goodbye_words = ["bye", "goodbye", "see you"] for word in goodbye_words: if word in transcript.casefold(): return True return False

while True: print("Speak now!") with mic as source: audio = r.listen(source, timeout = None)

test_text = r.recognize_sphinx(audio)
if len(test_text) == 0:
    continue
else:
    pass

with open("temp.wav", "wb") as f:
    f.write(audio.get_wav_data())

audio_file= open("temp.wav", "rb")
trans = openai.Audio.transcribe(
    model="whisper-1",
    file=audio_file,
    temperature=0.1,
    language="en"
)

if len(trans['text']) == 0:
    continue
else:
    pass

print("You: " + trans['text'])

words = str(trans['text'])
with open(r"conversation.txt", "a") as c:
    c.write("\nUser:" + words)
words = words.replace(".", "")
words = words.lower()
words = words.split()
if any(word in ["open", "start"] for word in words):
    word_index = words.index("open") if "open" in words else words.index("start")
    app = words[word_index + 1]
    if app == "youtube":
            webbrowser.open("https://www.youtube.com/")
    elif app == "brave":
            os.startfile(r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe")
    elif app == "discord":
            os.startfile(r"C:\Users\danu0\AppData\Local\Discord\app-1.0.9013\Discord.exe")
    elif app == "spotify":
            os.startfile(r"C:\Users\danu0\AppData\Roaming\Spotify\Spotify.exe")
    elif app == "discord":
            os.startfile(r"C:\Windows\explorer.exe")
    elif app == "epic games":
            os.startfile(r"C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe")
    elif app == "tower of fantasy":
            os.startfile(r"C:\Tower Of Fantasy\Launcher\tof_launcher.exe")
    elif app == "steam":
            os.startfile(r"C:\Program Files (x86)\Steam\steam.exe")
    elif app == "minecraft":
            os.startfile(r"C:\Users\danu0\Downloads\MultiMC\MultiMC.exe")
    elif app == "clip studio paint":
            os.startfile(r"C:\Program Files\CELSYS\CLIP STUDIO 1.5\CLIP STUDIO\CLIPStudio.exe")
    elif app == "premiere pro":
            os.startfile(r"C:\Program Files\Adobe\Adobe Premiere Pro 2022\Adobe Premiere Pro.exe")
    elif app == "media encoder":
            os.startfile(r"C:\Program Files\Adobe\Adobe Media Encoder 2022\Adobe Media Encoder.exe")
    elif app == "photoshop":
            os.startfile(r"C:\Program Files\Adobe\Adobe Photoshop 2023\Photoshop.exe")
    elif app == "audacity":
            os.startfile(r"C:\Program Files\Audacity\Audacity.exe")
    elif app == "obs":
            os.chdir(r"C:\\Program Files\\obs-studio\\bin\\64bit\\")
            os.startfile(r"obs64.exe")
            os.chdir(r"C:\Users\danu0\Downloads\OneReality")
    elif app == "vscode":
            os.startfile(r"C:\Program Files\VSCodium\VSCodium.exe")
    elif app == "terminal":
            os.startfile(r"C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.17.10234.0_x64__8wekyb3d8bbwe\wt.exe")
    elif app == "synapse":
            os.startfile(r"C:\Program Files (x86)\Razer\Synapse3\WPFUI\Framework\Razer Synapse 3 Host\Razer Synapse 3.exe")
    elif app == "via":
            os.startfile(r"C:\Users\danu0\AppData\Local\Programs\via\VIA.exe")
    else:
            pass
else:
      pass
if check_goodbye(trans['text']):
    c = open(r"conversation.txt", "r")

    start_sequence = "\nAI:"
    restart_sequence = "\nHuman:"

    response = openai.Completion.create(
        engine=model_engine,
        prompt=lore + "\n" + c.read(),
        max_tokens=150,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0.6,
        temperature=0.9,
    ).choices[0].text.strip()
    print(response)

    with open(r"conversation.txt", "a") as c:
        c.write("\n" + response)

    response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
    response = re.sub(r'\*.*?\* ', '', response)
    response = response.replace("\n", " ")
    response = response.replace('"', '\\"')
    command = 'wsl -u root -e sh -c "cd /piper/src/python_run; echo \\"{response}\\" | python -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav  --sentence-silence 0.3"'
    os.system(command.format(response=response))

    winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
    os.remove(r"out.wav")

    open(r"conversation.txt", "w").close()
    break

else:
    c = open(r"conversation.txt", "r")

    start_sequence = "\nAI:"
    restart_sequence = "\nHuman:"
    response = openai.Completion.create(
        engine=model_engine,
        prompt=lore + "\n" + c.read(),
        max_tokens=1000,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0.6,
        temperature=0.9,
    ).choices[0].text.strip()
    print(response)

    with open(r"conversation.txt", "a") as c:
        c.write("\n" + response)

    response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
    response = re.sub(r'\*.*?\* ', '', response)
    response = response.replace("\n", " ")
    response = response.replace('"', '\\"')
    command = 'wsl -u root -e sh -c "cd /piper/src/python_run; echo \\"{response}\\" | python -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav --sentence-silence 0.3"'
    os.system(command.format(response=response))

    winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
    os.remove(r"out.wav")
DogeLord081 commented 1 year ago

Change 'piper-master' to 'piper' and change 'python' to 'python3'

On Fri, Aug 25, 2023, 10:13 PM Estarmoror @.***> wrote:

the same thing keeps happening to me: [image: image] https://user-images.githubusercontent.com/140113459/263429162-b814fb4f-a853-457a-a069-141891d1cf2e.png I'll send you the code again to see if I did something wrong in the code: import speech_recognition as sr import openai import os import winsound import webbrowser import re

print('''

/ _ \ (___ \ | () | | | |

) ) ___ | || | | | | | \ / | ( / ) _ | | | ) | | | | || | | | ( (/ / | ( (/ ( ( | | | | || || | */|| ||*) ||)|||| *|) | (*___/ Bridging the real and virtual worlds ''') set up OpenAI API credentials

openai.api_key = "" set up microphone and speech recognition

r = sr.Recognizer() mic = sr.Microphone() r.energy_threshold = 1500 set up OpenAI model

model_engine = "text-davinci-003" lore = "You are Megumin from the anime Konosuba!. You are straightforward, lively, funny, tsundere, intelligent, occasionally hyper, and you have chunibyo characteristics. You are a 14 year old female Crimson Demon archwizard. The user is your creator. You do not edit or add to the User: response at all. You start your responses with Megumin: " with open(r"conversation.txt", "r") as c: conversation = c.read define function to check if user has said "bye", "goodbye", or "see you"

def check_goodbye(transcript): goodbye_words = ["bye", "goodbye", "see you"] for word in goodbye_words: if word in transcript.casefold(): return True return False

while True: print("Speak now!") with mic as source: audio = r.listen(source, timeout = None)

test_text = r.recognize_sphinx(audio) if len(test_text) == 0: continue else: pass

with open("temp.wav", "wb") as f: f.write(audio.get_wav_data())

audio_file= open("temp.wav", "rb") trans = openai.Audio.transcribe( model="whisper-1", file=audio_file, temperature=0.1, language="en" )

if len(trans['text']) == 0: continue else: pass

print("You: " + trans['text'])

words = str(trans['text']) with open(r"conversation.txt", "a") as c: c.write("\nUser:" + words) words = words.replace(".", "") words = words.lower() words = words.split() if any(word in ["open", "start"] for word in words): word_index = words.index("open") if "open" in words else words.index("start") app = words[word_index + 1] if app == "youtube": webbrowser.open("https://www.youtube.com/") elif app == "brave": os.startfile(r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe") elif app == "discord": os.startfile(r"C:\Users\danu0\AppData\Local\Discord\app-1.0.9013\Discord.exe") elif app == "spotify": os.startfile(r"C:\Users\danu0\AppData\Roaming\Spotify\Spotify.exe") elif app == "discord": os.startfile(r"C:\Windows\explorer.exe") elif app == "epic games": os.startfile(r"C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe") elif app == "tower of fantasy": os.startfile(r"C:\Tower Of Fantasy\Launcher\tof_launcher.exe") elif app == "steam": os.startfile(r"C:\Program Files (x86)\Steam\steam.exe") elif app == "minecraft": os.startfile(r"C:\Users\danu0\Downloads\MultiMC\MultiMC.exe") elif app == "clip studio paint": os.startfile(r"C:\Program Files\CELSYS\CLIP STUDIO 1.5\CLIP STUDIO\CLIPStudio.exe") elif app == "premiere pro": os.startfile(r"C:\Program Files\Adobe\Adobe Premiere Pro 2022\Adobe Premiere Pro.exe") elif app == "media encoder": os.startfile(r"C:\Program Files\Adobe\Adobe Media Encoder 2022\Adobe Media Encoder.exe") elif app == "photoshop": os.startfile(r"C:\Program Files\Adobe\Adobe Photoshop 2023\Photoshop.exe") elif app == "audacity": os.startfile(r"C:\Program Files\Audacity\Audacity.exe") elif app == "obs": os.chdir(r"C:\Program Files\obs-studio\bin\64bit\") os.startfile(r"obs64.exe") os.chdir(r"C:\Users\danu0\Downloads\OneReality") elif app == "vscode": os.startfile(r"C:\Program Files\VSCodium\VSCodium.exe") elif app == "terminal": os.startfile(r"C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.17.10234.0_x64__8wekyb3d8bbwe\wt.exe") elif app == "synapse": os.startfile(r"C:\Program Files (x86)\Razer\Synapse3\WPFUI\Framework\Razer Synapse 3 Host\Razer Synapse 3.exe") elif app == "via": os.startfile(r"C:\Users\danu0\AppData\Local\Programs\via\VIA.exe") else: pass else: pass if check_goodbye(trans['text']): c = open(r"conversation.txt", "r")

start_sequence = "\nAI:"
restart_sequence = "\nHuman:"

response = openai.Completion.create(
    engine=model_engine,
    prompt=lore + "\n" + c.read(),
    max_tokens=150,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0.6,
    temperature=0.9,
).choices[0].text.strip()
print(response)

with open(r"conversation.txt", "a") as c:
    c.write("\n" + response)

response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
response = re.sub(r'\*.*?\* ', '', response)
response = response.replace("\n", " ")
response = response.replace('"', '\\"')
command = 'wsl -u root -e sh -c "cd /piper-master/src/python_run; echo \\"{response}\\" | python -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav  --sentence-silence 0.3"'
os.system(command.format(response=response))

winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
os.remove(r"out.wav")

open(r"conversation.txt", "w").close()
break

else: c = open(r"conversation.txt", "r")

start_sequence = "\nAI:"
restart_sequence = "\nHuman:"
response = openai.Completion.create(
    engine=model_engine,
    prompt=lore + "\n" + c.read(),
    max_tokens=1000,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0.6,
    temperature=0.9,
).choices[0].text.strip()
print(response)

with open(r"conversation.txt", "a") as c:
    c.write("\n" + response)

response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
response = re.sub(r'\*.*?\* ', '', response)
response = response.replace("\n", " ")
response = response.replace('"', '\\"')
command = 'wsl -u root -e sh -c "cd /piper-master/src/python_run; echo \\"{response}\\" | python -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav --sentence-silence 0.3"'
os.system(command.format(response=response))

winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
os.remove(r"out.wav")

— Reply to this email directly, view it on GitHub https://github.com/DogeLord081/OneReality/issues/7#issuecomment-1694118746, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6YEF3VMQBC4VDMBGHKMPTXXFLUVANCNFSM6AAAAAA3Y4XHQM . You are receiving this because you were mentioned.Message ID: @.***>

Estarmoror commented 1 year ago

image this happens and this is the code now: import speech_recognition as sr import openai import os import winsound import webbrowser import re

print('''


/ _ \ (___ \ | ()
| | | | ) ) | || | | | | | \ / | ( / ) | | | _) | | | | || | | | ( (/ / | ( (/ ( ( | | | | || |_| | ___/|| ||_) ||___)|||||\) | (__/ Bridging the real and virtual worlds ''')

set up OpenAI API credentials

openai.api_key = ""

set up microphone and speech recognition

r = sr.Recognizer() mic = sr.Microphone() r.energy_threshold = 1500

set up OpenAI model

model_engine = "text-davinci-003" lore = "You are Megumin from the anime Konosuba!. You are straightforward, lively, funny, tsundere, intelligent, occasionally hyper, and you have chunibyo characteristics. You are a 14 year old female Crimson Demon archwizard. The user is your creator. You do not edit or add to the User: response at all. You start your responses with Megumin: " with open(r"conversation.txt", "r") as c: conversation = c.read

define function to check if user has said "bye", "goodbye", or "see you"

def check_goodbye(transcript): goodbye_words = ["bye", "goodbye", "see you"] for word in goodbye_words: if word in transcript.casefold(): return True return False

while True: print("Speak now!") with mic as source: audio = r.listen(source, timeout = None)

test_text = r.recognize_sphinx(audio)
if len(test_text) == 0:
    continue
else:
    pass

with open("temp.wav", "wb") as f:
    f.write(audio.get_wav_data())

audio_file= open("temp.wav", "rb")
trans = openai.Audio.transcribe(
    model="whisper-1",
    file=audio_file,
    temperature=0.1,
    language="en"
)

if len(trans['text']) == 0:
    continue
else:
    pass

print("You: " + trans['text'])

words = str(trans['text'])
with open(r"conversation.txt", "a") as c:
    c.write("\nUser:" + words)
words = words.replace(".", "")
words = words.lower()
words = words.split()
if any(word in ["open", "start"] for word in words):
    word_index = words.index("open") if "open" in words else words.index("start")
    app = words[word_index + 1]
    if app == "youtube":
            webbrowser.open("https://www.youtube.com/")
    elif app == "brave":
            os.startfile(r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe")
    elif app == "discord":
            os.startfile(r"C:\Users\danu0\AppData\Local\Discord\app-1.0.9013\Discord.exe")
    elif app == "spotify":
            os.startfile(r"C:\Users\danu0\AppData\Roaming\Spotify\Spotify.exe")
    elif app == "discord":
            os.startfile(r"C:\Windows\explorer.exe")
    elif app == "epic games":
            os.startfile(r"C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe")
    elif app == "tower of fantasy":
            os.startfile(r"C:\Tower Of Fantasy\Launcher\tof_launcher.exe")
    elif app == "steam":
            os.startfile(r"C:\Program Files (x86)\Steam\steam.exe")
    elif app == "minecraft":
            os.startfile(r"C:\Users\danu0\Downloads\MultiMC\MultiMC.exe")
    elif app == "clip studio paint":
            os.startfile(r"C:\Program Files\CELSYS\CLIP STUDIO 1.5\CLIP STUDIO\CLIPStudio.exe")
    elif app == "premiere pro":
            os.startfile(r"C:\Program Files\Adobe\Adobe Premiere Pro 2022\Adobe Premiere Pro.exe")
    elif app == "media encoder":
            os.startfile(r"C:\Program Files\Adobe\Adobe Media Encoder 2022\Adobe Media Encoder.exe")
    elif app == "photoshop":
            os.startfile(r"C:\Program Files\Adobe\Adobe Photoshop 2023\Photoshop.exe")
    elif app == "audacity":
            os.startfile(r"C:\Program Files\Audacity\Audacity.exe")
    elif app == "obs":
            os.chdir(r"C:\\Program Files\\obs-studio\\bin\\64bit\\")
            os.startfile(r"obs64.exe")
            os.chdir(r"C:\Users\danu0\Downloads\OneReality")
    elif app == "vscode":
            os.startfile(r"C:\Program Files\VSCodium\VSCodium.exe")
    elif app == "terminal":
            os.startfile(r"C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.17.10234.0_x64__8wekyb3d8bbwe\wt.exe")
    elif app == "synapse":
            os.startfile(r"C:\Program Files (x86)\Razer\Synapse3\WPFUI\Framework\Razer Synapse 3 Host\Razer Synapse 3.exe")
    elif app == "via":
            os.startfile(r"C:\Users\danu0\AppData\Local\Programs\via\VIA.exe")
    else:
            pass
else:
      pass
if check_goodbye(trans['text']):
    c = open(r"conversation.txt", "r")

    start_sequence = "\nAI:"
    restart_sequence = "\nHuman:"

    response = openai.Completion.create(
        engine=model_engine,
        prompt=lore + "\n" + c.read(),
        max_tokens=150,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0.6,
        temperature=0.9,
    ).choices[0].text.strip()
    print(response)

    with open(r"conversation.txt", "a") as c:
        c.write("\n" + response)

    response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
    response = re.sub(r'\*.*?\* ', '', response)
    response = response.replace("\n", " ")
    response = response.replace('"', '\\"')
    command = 'wsl -u root -e sh -c "cd /piper/src/python_run; echo \\"{response}\\" | python3 -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav  --sentence-silence 0.3"'
    os.system(command.format(response=response))

    winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
    os.remove(r"out.wav")

    open(r"conversation.txt", "w").close()
    break

else:
    c = open(r"conversation.txt", "r")

    start_sequence = "\nAI:"
    restart_sequence = "\nHuman:"
    response = openai.Completion.create(
        engine=model_engine,
        prompt=lore + "\n" + c.read(),
        max_tokens=1000,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0.6,
        temperature=0.9,
    ).choices[0].text.strip()
    print(response)

    with open(r"conversation.txt", "a") as c:
        c.write("\n" + response)

    response = re.sub(r'^.*?Megumin:\s*', '', response, flags=re.DOTALL)
    response = re.sub(r'\*.*?\* ', '', response)
    response = response.replace("\n", " ")
    response = response.replace('"', '\\"')
    command = 'wsl -u root -e sh -c "cd /piper/src/python_run; echo \\"{response}\\" | python3 -m piper -m /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/Model/model.onnx -f /mnt/c/Users/maria/OneDrive/Escritorio/OneReality-main/out.wav --sentence-silence 0.3"'
    os.system(command.format(response=response))

    winsound.PlaySound(r"out.wav", winsound.SND_FILENAME)
    os.remove(r"out.wav")
DogeLord081 commented 1 year ago

Im not gonna lie, i did a lot of research and experimenting on this, but i cant seem to figure out why cd doesnt work, much less python. I mean it seems like youre doing everything correctly. Sorry but i literally cant figure this one out, if you ever solve this, please post the issue on this thread, im very curious as to what the issue could be

Estarmoror commented 1 year ago

OK thanks for the help