update
This commit is contained in:
parent
902bab2a19
commit
a5dc6fb1a5
Binary file not shown.
Binary file not shown.
BIN
combined_video.mp4 (Stored with Git LFS)
BIN
combined_video.mp4 (Stored with Git LFS)
Binary file not shown.
BIN
output.wav (Stored with Git LFS)
BIN
output.wav (Stored with Git LFS)
Binary file not shown.
14
xtts.py
14
xtts.py
|
@ -35,8 +35,11 @@ def contect_gather(subject):
|
||||||
|
|
||||||
print(response.choices[0].message.content)
|
print(response.choices[0].message.content)
|
||||||
return response.choices[0].message.content
|
return response.choices[0].message.content
|
||||||
# Initialize TTS object
|
tts = True # Initialize tts as None initially
|
||||||
|
|
||||||
|
# Initialize TTS object if tts is True
|
||||||
if tts:
|
if tts:
|
||||||
|
from TTS.api import TTS
|
||||||
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
|
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
|
||||||
|
|
||||||
# Function to convert text to voice
|
# Function to convert text to voice
|
||||||
|
@ -44,8 +47,7 @@ def text_to_voice(text, speaker, language):
|
||||||
selected_ai = model_var.get()
|
selected_ai = model_var.get()
|
||||||
if selected_ai == 1:
|
if selected_ai == 1:
|
||||||
text_to_voice_openai(text)
|
text_to_voice_openai(text)
|
||||||
|
elif tts: # Check if tts is initialized before calling tts_to_file
|
||||||
else:
|
|
||||||
tts.tts_to_file(text=text,
|
tts.tts_to_file(text=text,
|
||||||
file_path="output.wav",
|
file_path="output.wav",
|
||||||
speaker_wav=f"sounds/{speaker}",
|
speaker_wav=f"sounds/{speaker}",
|
||||||
|
@ -53,6 +55,8 @@ def text_to_voice(text, speaker, language):
|
||||||
split_sentences=True
|
split_sentences=True
|
||||||
)
|
)
|
||||||
play_audio("output.wav")
|
play_audio("output.wav")
|
||||||
|
else:
|
||||||
|
print("TTS is not initialized. Set 'tts' to True and provide appropriate configuration.")
|
||||||
|
|
||||||
# Function to play audio using pygame
|
# Function to play audio using pygame
|
||||||
def play_audio(file_path):
|
def play_audio(file_path):
|
||||||
|
@ -93,7 +97,7 @@ def process_data():
|
||||||
multi_line_data = multi_line_textbox.get("1.0", tk.END)
|
multi_line_data = multi_line_textbox.get("1.0", tk.END)
|
||||||
text_to_voice(multi_line_data, selected_file, selected_language)
|
text_to_voice(multi_line_data, selected_file, selected_language)
|
||||||
print("Processing multi-line data, selected file, and selected language:", multi_line_data, selected_file, selected_language)
|
print("Processing multi-line data, selected file, and selected language:", multi_line_data, selected_file, selected_language)
|
||||||
|
combine_audio_video("output.wav", "original_video.webm", "combined_video.mp4")
|
||||||
# Function to save video
|
# Function to save video
|
||||||
def save_video():
|
def save_video():
|
||||||
# Code to save video
|
# Code to save video
|
||||||
|
@ -175,5 +179,5 @@ def display_output():
|
||||||
# Create save video button
|
# Create save video button
|
||||||
save_button = tk.Button(root, text="Save Video", command=combine_audio_video("output.wav", "original_video.webm", "combined_video.mp4"))
|
save_button = tk.Button(root, text="Save Video", command=combine_audio_video("output.wav", "original_video.webm", "combined_video.mp4"))
|
||||||
save_button.grid(row=7, column=0, columnspan=2, padx=10, pady=10, sticky="ew")
|
save_button.grid(row=7, column=0, columnspan=2, padx=10, pady=10, sticky="ew")
|
||||||
|
combine_audio_video("output.wav", "original_video.webm", "combined_video.mp4")
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
Loading…
Reference in New Issue