tuklu commited on
Commit
3f6702a
·
verified ·
1 Parent(s): 59a74e7

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -57,3 +57,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ wavs/*.wav filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .venv/
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11.9
align.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import stable_whisper
2
+ import whisper
3
+ import json
4
+
5
+ audio_path = "master.mp3"
6
+ transcript_path = "transcript.txt"
7
+ output_path = "aligned_transcription.json"
8
+
9
+ print("Loading 'medium' model via stable-whisper on GPU...")
10
+ model = stable_whisper.load_model('medium', device='cuda')
11
+
12
+ print(f"Loading transcript from: {transcript_path}")
13
+ with open(transcript_path, "r", encoding="utf-8") as f:
14
+ transcript_text = f.read()
15
+
16
+
17
+ print(f"Pre-loading audio from: {audio_path}")
18
+ audio_data = whisper.load_audio(audio_path)
19
+
20
+ print("Aligning audio and text on GPU with stable-whisper...")
21
+ result = model.align(audio_data, transcript_text, language='as')
22
+
23
+ print(f"Alignment complete. Saving results to {output_path}")
24
+ result_dict = result.to_dict()
25
+ with open(output_path, "w", encoding="utf-8") as f:
26
+ json.dump(result_dict, f, ensure_ascii=False, indent=2)
27
+
28
+ print("Process finished. You can download the JSON file from the sidebar.")
aligned_transcription.json ADDED
The diff for this file is too large to render. See raw diff
 
master.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a25b6229ac6901b2859e9a8575cff444bccfe02638a7f77e3b9ce9a57cd2323e
3
+ size 26429231
metadata.csv ADDED
The diff for this file is too large to render. See raw diff
 
pyproject.toml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "1hr-demo"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11.9"
7
+ dependencies = [
8
+ "pydub>=0.25.1",
9
+ "tts>=0.22.0",
10
+ "whisper>=1.1.10",
11
+ "whisper-timestamped>=1.15.9",
12
+ ]
segment.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from pydub import AudioSegment
3
+ import os
4
+ import sys
5
+
6
+ def segment_audio_from_alignment(audio_path, alignment_path):
7
+ """
8
+ Segments a long audio file into chunks based on a word-level
9
+ timestamped alignment file.
10
+ """
11
+
12
+ output_dir = "wavs"
13
+ metadata_path = "metadata.csv"
14
+ os.makedirs(output_dir, exist_ok=True)
15
+
16
+ print(f"Loading full audio from: {audio_path}")
17
+ try:
18
+ full_audio = AudioSegment.from_file(audio_path)
19
+ except Exception as e:
20
+ print(f"--- ERROR: Could not load the audio file. ---")
21
+ print(f"Ensure ffmpeg is correctly installed and the path is correct.")
22
+ print(f"Details: {e}")
23
+ sys.exit(1)
24
+
25
+ print(f"Loading alignment data from: {alignment_path}")
26
+ with open(alignment_path, 'r', encoding='utf-8') as f:
27
+ alignment_data = json.load(f)
28
+
29
+ with open(metadata_path, 'w', encoding='utf-8') as metadata_file:
30
+ print(f"Writing chunks to '{output_dir}' and metadata to '{metadata_path}'...")
31
+
32
+ chunk_counter = 0
33
+ for segment in alignment_data.get('segments', []):
34
+ for word_data in segment.get('words', []):
35
+ start_time = word_data.get('start')
36
+ end_time = word_data.get('end')
37
+ text = word_data.get('word', '').strip()
38
+
39
+ if start_time is None or end_time is None or not text:
40
+ continue
41
+
42
+ start_ms = int(start_time * 1000)
43
+ end_ms = int(end_time * 1000)
44
+
45
+ audio_chunk = full_audio[start_ms:end_ms]
46
+
47
+ chunk_counter += 1
48
+ chunk_filename = os.path.join(output_dir, f"chunk_{chunk_counter:05d}.wav")
49
+
50
+ audio_chunk.export(chunk_filename, format="wav")
51
+
52
+ metadata_file.write(f"{os.path.basename(output_dir)}/{os.path.basename(chunk_filename)}|{text}\n")
53
+
54
+ print(f"Processed {chunk_counter} audio chunks.")
55
+
56
+ def main():
57
+ audio_file = "master.mp3"
58
+ alignment_file = "aligned_transcription.json"
59
+
60
+ if not os.path.exists(audio_file) or not os.path.exists(alignment_file):
61
+ print("--- ERROR: Make sure 'master.mp3' and 'aligned_transcription.json' are in the project directory. ---")
62
+ sys.exit(1)
63
+
64
+ segment_audio_from_alignment(audio_file, alignment_file)
65
+
66
+ if __name__ == "__main__":
67
+ main()
transcribe.txt ADDED
The diff for this file is too large to render. See raw diff
 
uv.lock ADDED
The diff for this file is too large to render. See raw diff
 
wavs/chunk_00001.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:604c2fdd4920c7d0d2cbcbea327eb85baf02317c0700b70a8712d9da3260b00e
3
+ size 35324
wavs/chunk_00002.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e74d7c24063b7d560474100bad463e7c27a7df2a273c3058ffb496536509c935
3
+ size 91772
wavs/chunk_00003.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b0860b85b7de833ba1a828456fcdc92e4e8632c7f5ae50660e18421499dbf4b
3
+ size 42380
wavs/chunk_00004.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:573c11beb7f70cfc157ee53a2e6e9cc7c8954132239a24096beccc3ee73fd9d8
3
+ size 35324
wavs/chunk_00005.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00006.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10a946f88560e32e8354a3bd4ece138db2abd4c14300864a06782498b8188686
3
+ size 119996
wavs/chunk_00007.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03947a182aa6c6d1479728f9182ac9f4fc150cd0cbc2ff5af74d8aa7a6e48112
3
+ size 95300
wavs/chunk_00008.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c8eb16cade898806de01c5f55fffe803a2cbf99284694bfe99d1c74ae010eee
3
+ size 211724
wavs/chunk_00009.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f82a930c18289b543520cfe77440e088157bd7c2f6fc88fd256e1b5c70d59b1e
3
+ size 56492
wavs/chunk_00010.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00011.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:542586be205b5520519322a8d928258b21ce3386cfca40a311ace3cb69573339
3
+ size 91772
wavs/chunk_00012.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f94a5e3082f874da84759b7ce44f54c27485693645b977138c5eeafe55dc5532
3
+ size 201140
wavs/chunk_00013.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00014.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00015.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00016.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00017.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00018.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00019.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00020.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46ac35869890fb847ddf079172fb121e5aa786427c62fce3e1fbfc5a08465d3f
3
+ size 35324
wavs/chunk_00021.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00022.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00023.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00024.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00025.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00026.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00027.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00028.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00029.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00030.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00031.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00032.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00033.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00034.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00035.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00036.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00037.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00038.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44
wavs/chunk_00039.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:991cd2a53281fab26a26b23f2b3d7a020e277b83978ea36796679e0952ae7575
3
+ size 44