def __init__(self):
     if(Speech2LandmarkModel=="Eskimez"):
         self.audio_landmark_model = initiate_model()            
     elif(Speech2LandmarkModel=="speechdriven"):
         self.va = sda.VideoAnimator(gpu=0,model_path="timit")
         
         self.still_frame = cv2.imread(os.path.join(os.path.dirname(root_file_path),"example/d.png"))
         self.still_frame = cv2.cvtColor(self.still_frame,cv2.COLOR_BGR2RGB)
Exemple #2
0
def Speech_To_Animation(img_option):
    speech_key, service_region = "ab60b285299b4dfcb03ef97c2e8dd59a", "eastasia"
    speech_config = speechsdk.SpeechConfig(subscription=speech_key,
                                           region=service_region)

    speech_filename = './Resource/speech.wav'
    audio_config = speechsdk.audio.AudioConfig(filename=speech_filename)
    speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config,
                                                   audio_config=audio_config)
    STT_result = speech_recognizer.recognize_once()
    if STT_result.reason == speechsdk.ResultReason.RecognizedSpeech:
        print("Recognized: {}".format(STT_result.text))
    elif STT_result.reason == speechsdk.ResultReason.NoMatch:
        print("No speech could be recognized")
    elif STT_result.reason == speechsdk.ResultReason.Canceled:
        cancellation_details = STT_result.cancellation_details
        print("Speech Recognition canceled: {}".format(
            cancellation_details.reason))
        if cancellation_details.reason == speechsdk.CancellationReason.Error:
            print("Error details: {}".format(
                cancellation_details.error_details))
    print("STT Done.")

    voice = "Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS)"
    #voice = "en-US-GuyNeural"
    speech_config.speech_synthesis_voice_name = voice
    file_name = "./Resource/rightAudio.wav"
    if os.path.exists(file_name):
        os.remove(file_name)
    file_config = speechsdk.audio.AudioOutputConfig(filename=file_name)
    speech_synthesizer = speechsdk.SpeechSynthesizer(
        speech_config=speech_config, audio_config=file_config)
    result = speech_synthesizer.speak_text_async(STT_result.text).get()
    if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
        print(
            "Speech synthesized for text [{}], and the audio was saved to [{}]"
            .format(STT_result.text, file_name))
    elif result.reason == speechsdk.ResultReason.Canceled:
        cancellation_details = result.cancellation_details
        print("Speech synthesis canceled: {}".format(
            cancellation_details.reason))
        if cancellation_details.reason == speechsdk.CancellationReason.Error:
            print("Error details: {}".format(
                cancellation_details.error_details))
    print("TTS Done.")

    va = sda.VideoAnimator(model_path="grid")  # Instantiate the animator
    if img_option:
        source_path = "Resource/userFace.bmp"
    else:
        source_path = "Resource/speaker1.bmp"
    vid, aud = va(source_path, "./Resource/rightAudio.wav")
    va.save_video(vid, aud, "./Resource/right.mp4")
    vid, aud = va(source_path, "./Resource/speech.wav")
    va.save_video(vid, aud, "./Resource/wrong.mp4")
    print("SDA Done.")
Exemple #3
0
import sda
va = sda.VideoAnimator(model_path="crema")
Exemple #4
0
import sda
import sys
from csv import writer
import tkinter
from tkinter.filedialog import askopenfilename
from pathlib import Path
import os

print(sys.path)
print(sys.argv[1])
print("------------------------BREAK-----------------------------------")

videoPath = sys.argv[1]
audioPath = sys.argv[2]
video = videoPath
audio = audioPath

va = sda.VideoAnimator(
    model_path=
    "C:/Users/Robijntje/Documents/EHB/FP3/FINAL SITE/fullproject3-main/deepfake/sda/data/grid.dat"
)  # Instantiate the animator
vid, aud = va(video, audio)
va.save_video(vid, aud, "../deepfake/generated.mp4")
#zoek voor mp4 output naar node.js
Exemple #5
0
import sda
va = sda.VideoAnimator(model_path="C:/Users/Robijntje/Documents/EHB/FP3/speech-driven-animation-master/sda/data/grid.dat")# Instantiate the animator

vid, aud = va("C:/Users/Robijntje/Documents/EHB/FP3/speech-driven-animation-master/example/robin.jpg", "C:/Users/Robijntje/Documents/EHB/FP3/speech-driven-animation-master/example/audio9.wav")
va.save_video(vid, aud, "./generated.mp4")  
Exemple #6
0
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
import sda
va = sda.VideoAnimator(gpu=0, model_path="crema")
name=sys.argv[1]
#vid, aud = va('./uploads/images/' + name + '.png','./uploads/records/' + name + '.m4a')
vid, aud = va('./uploads/images/' + name + '.jpeg','./uploads/records/' + name + '.m4a')	
va.save_video(vid, aud, './uploads/videos/'+name+'.mp4')
Exemple #7
0
def initiate_video():
    va = sda.VideoAnimator(model_path="grid")
    vid, aud = va("input/image.bmp", "input/audio.mp3")
    va.save_video(vid, aud, "static/generated.mp4")
    # ffmpeg -i generated.mp4 -vcodec h264 generated1.mp4
    print("Video done")