big debug amélioration enregistrement
This commit is contained in:
+35
-42
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import argparse
|
||||
import json
|
||||
@@ -35,42 +34,31 @@ from fonction.first_class import messageTwitch
|
||||
from fonction.second_fonction import *
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
os.system('killall python')
|
||||
sys.exit(0)
|
||||
# def signal_handler():
|
||||
# os.system('killall python')
|
||||
# sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
console = Console()
|
||||
|
||||
|
||||
def send_message(tw_acc_pseudo, tw_acc_token, channel_name, Message_text):
|
||||
hprint("green","start send_message")
|
||||
|
||||
command = '-pseudo "'+tw_acc_pseudo+'" -token "'+tw_acc_token+'" -twitchname "'+channel_name+'" -message " Kappa '+Message_text+'"'
|
||||
message_tosend = 'python send_message.py '+command
|
||||
hprint("yellow",f"send message = "+str(message_tosend))
|
||||
#subprocess.run(message_tosend, shell=True)
|
||||
hprint("yellow",f"Finnish send message")
|
||||
|
||||
|
||||
def stop_all():
|
||||
hprint("blue", "Arrêt d'enregistrement twitch.")
|
||||
recordTw.stop()
|
||||
sb_translation.stop()
|
||||
# signal_handler()
|
||||
|
||||
def print_help():
|
||||
hprint("PURPLE", "Touche 'F5'BOT Active l'écoute clavier")
|
||||
hprint("PURPLE", "Touche 'F6'BOT Désactive l'écoute clavier")
|
||||
hprint("PURPLE", "Touche h : pour afficher les commandes")
|
||||
hprint("PURPLE", "Touche q : pour quitter le sript")
|
||||
hprint("PURPLE", "Touche c : Clear le terminal")
|
||||
hprint("PURPLE", "Touche s : envoie un message dans le tchat twitch avec la derniere génération")
|
||||
|
||||
hprint("PURPLE", "Touche u : pour stopper lenregistrement twitch")
|
||||
# hprint("PURPLE", "Touche j : pour start lenregistrement twitch") # pas set
|
||||
|
||||
# hprint("PURPLE", "Touche i : pour start la traduction en text du record") # pas set
|
||||
hprint("PURPLE", "Touche p : pour stopper la traduction en text du record")
|
||||
hprint("PURPLE", "Touche o : liste tout les sous titre créé")
|
||||
|
||||
hprint("PURPLE", "Touche k : lancer une generation de reponse avec ia depuis les traduction")
|
||||
hprint("PURPLE", "Touche l : liste toute les génération")
|
||||
hprint("PURPLE", "Touche m : change le prompt a donner a l'ia")
|
||||
@@ -107,9 +95,9 @@ def on_press(key):
|
||||
if listening_keyboard:
|
||||
if key.char == 'q': # Si la touche 'q' est pressée, arrête l'écoute
|
||||
hprint("cyan", "Touche 'q' détectée. Fin du programme.")
|
||||
main_loop = False
|
||||
stop_all()
|
||||
return False # Cela arrêtera l'écouteur
|
||||
main_loop = False
|
||||
# return False # Cela arrêtera l'écouteur
|
||||
elif key.char == 'c':
|
||||
hprint("cyan", "Touche 'c' clear terminal")
|
||||
clear_screen()
|
||||
@@ -125,7 +113,7 @@ def on_press(key):
|
||||
elif key.char == 's':
|
||||
hprint("cyan", "Touche 's' Envoie du message")
|
||||
Message_text = ask_text.getlast_generation()
|
||||
#send_message(tw_acc_pseudo, tw_acc_token, args.twitchname, Message_text)
|
||||
controluser.send_message(Message_text)
|
||||
elif key.char == 'o':
|
||||
hprint("cyan", "Touche 'o'liste sous titre")
|
||||
sb_translation.print_allsubtitle()
|
||||
@@ -154,54 +142,59 @@ def generation_responce():
|
||||
if __name__ == '__main__':
|
||||
main_loop = True
|
||||
|
||||
#configuration du dossier de travaille
|
||||
work_directory = "working_bot"
|
||||
if not os.path.exists(work_directory):
|
||||
os.makedirs(work_directory)
|
||||
hprint("green", "création du dossier : "+work_directory)
|
||||
os.chdir(work_directory)
|
||||
|
||||
#récupération du fichier de configuration
|
||||
with open("../config/config.json", 'r') as file:
|
||||
config = json.load(file)
|
||||
tw_acc_pseudo = get_value_json("tw_acc_pseudo", config)
|
||||
tw_acc_token = get_value_json("tw_acc_token", config)
|
||||
|
||||
#récupération des arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-threads', type=int, default=10, help='Number of threads')
|
||||
parser.add_argument('-recordtime', type=int, default=60, help='Time to record')
|
||||
parser.add_argument('-twitchname', type=str, required=True, help='Twitch channel name')
|
||||
args = parser.parse_args()
|
||||
|
||||
#lancement de la class d'enregistrement audio du stream
|
||||
hprint("blue", "start loop RecordTwitch")
|
||||
recordTw = RecordTwitch(channel_name=args.twitchname, recordtime=args.recordtime)
|
||||
recordTw.start_recording()
|
||||
recordTw = RecordTwitch(channel_name=args.twitchname, record_time=args.recordtime)
|
||||
recordTw.main()
|
||||
|
||||
hprint("blue", "start loop Subtitle_translation")
|
||||
sb_translation = Subtitle_translation("../config/config.json")
|
||||
sb_translation.start_main_loop()
|
||||
|
||||
ask_text = IA_generator("../config/config.json")
|
||||
ask_text.start_main_loop()
|
||||
#ask_text = IA_generator("../config/config.json")
|
||||
#ask_text.start_main_loop()
|
||||
|
||||
controluser = messageTwitch(args.twitchname)
|
||||
#controluser = messageTwitch(args.twitchname)
|
||||
|
||||
print_help()
|
||||
listener_thread = threading.Thread(target=start_keyboard_listener)
|
||||
listener_thread.start() # mise en thread de l'écoute des appuye touche
|
||||
|
||||
|
||||
time.sleep(25)
|
||||
last_generaton = ""
|
||||
while main_loop:
|
||||
hprint("blue", "start main_loop main script")
|
||||
text_streamer = sb_translation.get_lasttext()
|
||||
ask_text.setnew_streamer_word_text(text_streamer)
|
||||
new_genration = ask_text.getlast_generation()
|
||||
#time.sleep(25)
|
||||
#last_generaton = ""
|
||||
#while main_loop:
|
||||
#time.sleep(3)
|
||||
#hprint("blue", "start main_loop main script")
|
||||
#text_streamer = sb_translation.get_lasttext()
|
||||
#ask_text.setnew_streamer_word_text(text_streamer)
|
||||
#new_genration = ask_text.getlast_generation()
|
||||
|
||||
if new_genration != "" and new_genration != last_generaton:
|
||||
hprint("blue", "Send message -> "+new_genration)
|
||||
# send_message(tw_acc_pseudo, tw_acc_token, args.twitchname, new_genration)
|
||||
controluser.send_message(new_genration)
|
||||
controluser.change_user()
|
||||
last_generaton = new_genration
|
||||
#if new_genration != "" and new_genration != last_generaton:
|
||||
#hprint("blue", "Send message -> "+new_genration)
|
||||
#controluser.send_message(new_genration)
|
||||
#controluser.change_user()
|
||||
#last_generaton = new_genration
|
||||
|
||||
time.sleep(25)
|
||||
#time.sleep(10)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user