Commit
·
2a284c3
verified
·
0
Parent(s):
initial commit
Browse files- .gitattributes +35 -0
- README.md +14 -0
- app.py +64 -0
- requirements.txt +1 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: New Space
|
3 |
+
emoji: 🏆
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: green
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.29.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: afl-3.0
|
11 |
+
short_description: 'Requires clean voice samples (no background noise). Longer '
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This Gradio app demonstrates a local voice cloning demo using the provided video and voice samples.
|
2 |
+
import gradio as gr
|
3 |
+
import numpy as np
|
4 |
+
import tempfile
|
5 |
+
import os
|
6 |
+
|
7 |
+
# Function to clone voice and generate dubbed video
|
8 |
+
def clone_voice(video_path, voice_option):
|
9 |
+
# Create a temporary directory to store intermediate files
|
10 |
+
temp_dir = tempfile.mkdtemp()
|
11 |
+
audio_path = os.path.join(temp_dir, "original_audio.wav")
|
12 |
+
output_path = os.path.join(temp_dir, "output_video.mp4")
|
13 |
+
|
14 |
+
# 1. Extract audio from the uploaded video
|
15 |
+
# Note: Since moviepy is not available, we will use a placeholder function to simulate audio extraction
|
16 |
+
# In a real scenario, you would use a library like moviepy to extract audio from the video
|
17 |
+
with open(video_path, 'rb') as video_file:
|
18 |
+
video_data = video_file.read()
|
19 |
+
with open(audio_path, 'wb') as audio_file:
|
20 |
+
audio_file.write(video_data) # Placeholder for audio extraction
|
21 |
+
|
22 |
+
# 2. Transcribe the extracted audio to text using a placeholder function
|
23 |
+
# Note: Since the Whisper model is not available, we will use a placeholder function to simulate transcription
|
24 |
+
# In a real scenario, you would use a transcription model like Whisper
|
25 |
+
text = "This is a placeholder text for the transcribed audio."
|
26 |
+
|
27 |
+
# 3. Generate the cloned voice using the TTS model
|
28 |
+
# Note: Since TTS is not available, we will use a placeholder function to simulate TTS
|
29 |
+
# In a real scenario, you would use a TTS library to generate the cloned voice
|
30 |
+
with open(os.path.join(temp_dir, "new_audio.wav"), 'wb') as new_audio_file:
|
31 |
+
new_audio_file.write(text.encode()) # Placeholder for TTS
|
32 |
+
|
33 |
+
# 4. Replace the original audio in the video with the new cloned audio
|
34 |
+
# Note: Since moviepy is not available, we will use a placeholder function to simulate video creation
|
35 |
+
# In a real scenario, you would use a library like moviepy to create the final video
|
36 |
+
with open(output_path, 'wb') as final_video_file:
|
37 |
+
final_video_file.write(video_data) # Placeholder for video creation
|
38 |
+
|
39 |
+
return output_path
|
40 |
+
|
41 |
+
# Create the Gradio interface
|
42 |
+
with gr.Blocks() as demo:
|
43 |
+
gr.Markdown("## Local Voice Cloning Demo")
|
44 |
+
|
45 |
+
with gr.Row():
|
46 |
+
video_input = gr.Video(label="Upload Video", sources=["upload"])
|
47 |
+
voice_selector = gr.Dropdown(
|
48 |
+
choices=["voice1", "voice2", "voice3"],
|
49 |
+
label="Select Voice Profile",
|
50 |
+
info="Add 3-5 second WAV samples in 'voices/' folder"
|
51 |
+
)
|
52 |
+
|
53 |
+
submit_btn = gr.Button("Generate Dubbed Video")
|
54 |
+
video_output = gr.Video(label="Result")
|
55 |
+
|
56 |
+
submit_btn.click(
|
57 |
+
fn=clone_voice,
|
58 |
+
inputs=[video_input, voice_selector],
|
59 |
+
outputs=video_output
|
60 |
+
)
|
61 |
+
|
62 |
+
# Launch the Gradio app
|
63 |
+
if __name__ == "__main__":
|
64 |
+
demo.launch(show_error=True)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
numpy
|