Spaces:
Sleeping
Sleeping
Commit ·
fca10b5
1
Parent(s): 0646f1a
fix: __future__ import ordering in enrollment.py patch
Browse files- prepare_space.ps1 +6 -3
- vocal_mirror/enrollment.py +1 -1
prepare_space.ps1
CHANGED
|
@@ -105,14 +105,17 @@ python $ttsTempScript $TtsPyPath
|
|
| 105 |
Write-Host "Patching enrollment.py with @spaces.GPU on extract_embedding..."
|
| 106 |
$EnrollPyPath = Join-Path $TargetDir "enrollment.py"
|
| 107 |
$enrollPatchScript = @"
|
| 108 |
-
import sys
|
| 109 |
path = sys.argv[1]
|
| 110 |
with open(path, 'r', encoding='utf-8') as f:
|
| 111 |
code = f.read()
|
| 112 |
if 'import spaces' not in code:
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
| 114 |
if '@spaces.GPU\ndef extract_embedding(' not in code:
|
| 115 |
-
code =
|
| 116 |
with open(path, 'w', encoding='utf-8') as f:
|
| 117 |
f.write(code)
|
| 118 |
"@
|
|
|
|
| 105 |
Write-Host "Patching enrollment.py with @spaces.GPU on extract_embedding..."
|
| 106 |
$EnrollPyPath = Join-Path $TargetDir "enrollment.py"
|
| 107 |
$enrollPatchScript = @"
|
| 108 |
+
import sys, re
|
| 109 |
path = sys.argv[1]
|
| 110 |
with open(path, 'r', encoding='utf-8') as f:
|
| 111 |
code = f.read()
|
| 112 |
if 'import spaces' not in code:
|
| 113 |
+
if 'from __future__' in code:
|
| 114 |
+
code = re.sub(r'((?:from __future__[^\n]*\n)+)', r'\1import spaces\n', code, count=1)
|
| 115 |
+
else:
|
| 116 |
+
code = 'import spaces\n' + code
|
| 117 |
if '@spaces.GPU\ndef extract_embedding(' not in code:
|
| 118 |
+
code = re.sub(r'(?m)^def extract_embedding\(', '@spaces.GPU\ndef extract_embedding(', code, count=1)
|
| 119 |
with open(path, 'w', encoding='utf-8') as f:
|
| 120 |
f.write(code)
|
| 121 |
"@
|
vocal_mirror/enrollment.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import spaces
|
| 2 |
"""Speaker enrollment — WavLM-based embedding extraction and session management.
|
| 3 |
|
| 4 |
Records two audio segments, extracts WavLM-Base+ speaker embeddings,
|
|
@@ -7,6 +6,7 @@ No embeddings are written to disk.
|
|
| 7 |
"""
|
| 8 |
|
| 9 |
from __future__ import annotations
|
|
|
|
| 10 |
|
| 11 |
import time
|
| 12 |
import uuid
|
|
|
|
|
|
|
| 1 |
"""Speaker enrollment — WavLM-based embedding extraction and session management.
|
| 2 |
|
| 3 |
Records two audio segments, extracts WavLM-Base+ speaker embeddings,
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
from __future__ import annotations
|
| 9 |
+
import spaces
|
| 10 |
|
| 11 |
import time
|
| 12 |
import uuid
|