marcosremar2 commited on
Commit
5fe98b2
·
1 Parent(s): d1991e8

Final deployment: working server with model download fix

Browse files
app.py.bak ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import tempfile
4
+ import time
5
+ import subprocess
6
+ import ssl
7
+ import threading
8
+ import functools
9
+ from flask import Flask, request, jsonify
10
+ from flask_cors import CORS
11
+ from werkzeug.utils import secure_filename
12
+ from allosaurus.app import read_recognizer
13
+
14
+ app = Flask(__name__)
15
+ CORS(app)
16
+
17
+ CACHE_DIR = "/tmp/cache"
18
+ UPLOAD_FOLDER = 'uploads'
19
+ ALLOWED_EXTENSIONS = {'wav', 'ogg', 'mp3', 'm4a'}
20
+
21
+ os.makedirs("/tmp/uploads", exist_ok=True)
22
+ os.makedirs("/tmp/cache", exist_ok=True)
23
+
24
+ # Disable SSL verification for model download
25
+ ssl._create_default_https_context = ssl._create_unverified_context
26
+ os.environ['PYTHONHTTPSVERIFY'] = '0'
27
+
28
+ import torch
29
+
30
+ # Preload the model at server startup
31
+ print("Preloading Allosaurus model...")
32
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
33
+ print(f"Using device: {device}")
34
+ MODEL = read_recognizer(alt_model_path="/tmp/allosaurus_models", skip_download=True, model_dir="/tmp/allosaurus_models")
35
+ if device == 'cuda':
36
+ MODEL.model.to(device)
37
+
38
+ # Create a phoneme to viseme mapping dictionary for faster lookups
39
+ PHONEME_MAP = {}
40
+ vowels = ['a', 'e', 'i', 'o', 'u', 'æ', 'ɑ', 'ɒ', 'ɔ', 'ɛ', 'ɜ', 'ɪ', 'ʊ', 'ʌ', 'ə', 'ɐ']
41
+ bilabials = ['b', 'p', 'm']
42
+ labiodentals = ['f', 'v']
43
+ dentals = ['θ', 'ð']
44
+ alveolars = ['t', 'd', 'n', 's', 'z', 'l', 'r']
45
+ palatals = ['ʃ', 'ʒ', 'j', 'tʃ', 'dʒ']
46
+ velars = ['k', 'g', 'ŋ', 'x']
47
+
48
+ # Build the mapping dictionary
49
+ for p in bilabials:
50
+ PHONEME_MAP[p] = 'A' # MBP
51
+
52
+ for p in labiodentals + dentals:
53
+ PHONEME_MAP[p] = 'G' # FV
54
+
55
+ for p in alveolars:
56
+ if p == 'l':
57
+ PHONEME_MAP[p] = 'H' # L
58
+ else:
59
+ PHONEME_MAP[p] = 'B' # etc
60
+
61
+ for p in palatals + velars:
62
+ PHONEME_MAP[p] = 'B' # etc
63
+
64
+ for p in vowels:
65
+ if p in ['a', 'æ', 'ɑ', 'ɒ']:
66
+ PHONEME_MAP[p] = 'D' # AI
67
+ elif p in ['e', 'ɛ', 'ɪ', 'i']:
68
+ PHONEME_MAP[p] = 'C' # E
69
+ elif p in ['o', 'ɔ', 'ʌ', 'ə', 'ɐ', 'ɜ']:
70
+ PHONEME_MAP[p] = 'E' # O
71
+ elif p in ['u', 'ʊ']:
72
+ PHONEME_MAP[p] = 'F' # U
73
+ else:
74
+ PHONEME_MAP[p] = 'C' # Default vowel
75
+
76
+ # Cache for processed results
77
+ RESULT_CACHE = {}
78
+
79
+ def allowed_file(filename):
80
+ return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
81
+
82
+ def convert_to_wav(input_file):
83
+ output_file = os.path.splitext(input_file)[0] + '.wav'
84
+ try:
85
+ subprocess.run(['ffmpeg', '-i', input_file, '-acodec', 'pcm_s16le', '-ar', '16000', output_file],
86
+ check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
87
+ return output_file
88
+ except subprocess.CalledProcessError:
89
+ return None
90
+
91
+ def map_phoneme_to_viseme(phoneme):
92
+ # Fast lookup using the precomputed dictionary
93
+ return PHONEME_MAP.get(phoneme, 'X') # Default to 'X' if not found
94
+
95
+ def get_file_hash(filepath):
96
+ # Simple file hash based on file size and modification time
97
+ stat = os.stat(filepath)
98
+ return f"{stat.st_size}_{stat.st_mtime}"
99
+
100
+ def process_audio_with_allosaurus(audio_file):
101
+ # Optimized cache check with LRU eviction
102
+ file_hash = get_file_hash(audio_file)
103
+ cache_key = f"{os.path.basename(audio_file)}_{file_hash}"
104
+
105
+ if cache_key in RESULT_CACHE:
106
+ # Move to front of cache for LRU
107
+ result = RESULT_CACHE.pop(cache_key)
108
+ RESULT_CACHE[cache_key] = result
109
+ return result
110
+
111
+ start_time = time.time()
112
+
113
+ # Convert to WAV if not already in WAV format
114
+ if not audio_file.lower().endswith('.wav'):
115
+ wav_file = convert_to_wav(audio_file)
116
+ if not wav_file:
117
+ return None
118
+ audio_file = wav_file
119
+
120
+ # Recognize phonemes using the preloaded model
121
+ if device == 'cuda':
122
+ with torch.no_grad():
123
+ phonemes = MODEL.recognize(audio_file, timestamp=True)
124
+ else:
125
+ phonemes = MODEL.recognize(audio_file, timestamp=True)
126
+
127
+ # Process the phonemes into visemes
128
+ mouth_cues = []
129
+
130
+ # Parse the phoneme output
131
+ lines = phonemes.strip().split('\n')
132
+
133
+ for line in lines:
134
+ parts = line.split()
135
+ if len(parts) >= 3:
136
+ start_time_val = float(parts[0])
137
+ duration = float(parts[1])
138
+ phoneme = parts[2]
139
+
140
+ # Map phoneme to viseme using the fast lookup
141
+ viseme = map_phoneme_to_viseme(phoneme)
142
+
143
+ # Calculate end time
144
+ end_time_val = start_time_val + duration
145
+
146
+ # Add to mouth cues
147
+ mouth_cues.append({
148
+ "start": round(start_time_val, 2),
149
+ "end": round(end_time_val, 2),
150
+ "value": viseme
151
+ })
152
+
153
+ # Add rest position at the beginning if needed
154
+ if mouth_cues and mouth_cues[0]["start"] > 0:
155
+ mouth_cues.insert(0, {
156
+ "start": 0,
157
+ "end": mouth_cues[0]["start"],
158
+ "value": "X"
159
+ })
160
+
161
+ # Get audio duration
162
+ try:
163
+ result = subprocess.run(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of',
164
+ 'default=noprint_wrappers=1:nokey=1', audio_file],
165
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
166
+ duration = float(result.stdout.strip())
167
+ except:
168
+ # If ffprobe fails, estimate duration from the last phoneme
169
+ duration = mouth_cues[-1]["end"] if mouth_cues else 0
170
+
171
+ # Add rest position at the end if needed
172
+ if mouth_cues and mouth_cues[-1]["end"] < duration:
173
+ mouth_cues.append({
174
+ "start": mouth_cues[-1]["end"],
175
+ "end": duration,
176
+ "value": "X"
177
+ })
178
+
179
+ # Create result in the same format as Rhubarb for compatibility
180
+ result = {
181
+ "metadata": {
182
+ "soundFile": audio_file,
183
+ "duration": duration
184
+ },
185
+ "mouthCues": mouth_cues
186
+ }
187
+
188
+ # Cache with size limit (100 items)
189
+ if len(RESULT_CACHE) >= 100:
190
+ RESULT_CACHE.pop(next(iter(RESULT_CACHE)))
191
+ RESULT_CACHE[cache_key] = result
192
+
193
+ processing_time = time.time() - start_time
194
+ print(f"Processing completed in {processing_time:.2f} seconds")
195
+
196
+ return result
197
+
198
+ @app.route('/api/viseme', methods=['POST'])
199
+ def generate_viseme():
200
+ if 'file' not in request.files:
201
+ return jsonify({'error': 'No file part'}), 400
202
+
203
+ file = request.files['file']
204
+
205
+ if file.filename == '':
206
+ return jsonify({'error': 'No selected file'}), 400
207
+
208
+ if file and allowed_file(file.filename):
209
+ filename = secure_filename(file.filename)
210
+ filepath = os.path.join(UPLOAD_FOLDER, filename)
211
+ file.save(filepath)
212
+
213
+ result = process_audio_with_allosaurus(filepath)
214
+
215
+ # Don't delete the file immediately to allow caching to work
216
+ # We'll clean up old files periodically
217
+
218
+ if result:
219
+ return jsonify(result)
220
+ else:
221
+ return jsonify({'error': 'Failed to process audio file'}), 500
222
+
223
+ return jsonify({'error': 'File type not allowed'}), 400
224
+
225
+ @app.route('/api/status', methods=['GET'])
226
+ def status():
227
+ return jsonify({
228
+ 'status': 'ok',
229
+ 'model_loaded': MODEL is not None,
230
+ 'cache_size': len(RESULT_CACHE),
231
+ 'supported_formats': list(ALLOWED_EXTENSIONS)
232
+ })
233
+
234
+ @app.route('/health', methods=['GET'])
235
+ def health_check():
236
+ return jsonify({'status': 'ok'})
237
+
238
+ def cleanup_old_files():
239
+ # Clean up files older than 1 hour
240
+ now = time.time()
241
+ for filename in os.listdir(UPLOAD_FOLDER):
242
+ filepath = os.path.join(UPLOAD_FOLDER, filename)
243
+ if os.path.isfile(filepath) and now - os.path.getmtime(filepath) > 3600:
244
+ os.unlink(filepath)
245
+
246
+ if __name__ == '__main__':
247
+ # Start a background thread to clean up old files
248
+ cleanup_thread = threading.Thread(target=lambda: (
249
+ time.sleep(3600), # Run every hour
250
+ cleanup_old_files()
251
+ ))
252
+ cleanup_thread.daemon = True
253
+ cleanup_thread.start()
254
+
255
+ # Configure hot reload with increased watcher sensitivity
256
+ app.run(host='0.0.0.0',
257
+ port=7860,
258
+ debug=True,
259
+ use_reloader=True,
260
+ reloader_type='stat',
261
+ extra_files=['./requirements.txt'],
262
+ reloader_interval=1)
requirements.txt CHANGED
@@ -5,5 +5,5 @@ python-dotenv==0.19.0
5
  werkzeug==2.0.1
6
  allosaurus>=1.0.2
7
  numpy<2.0.0
8
- torch==1.13.1
9
- torchaudio==0.13.1
 
5
  werkzeug==2.0.1
6
  allosaurus>=1.0.2
7
  numpy<2.0.0
8
+ torch==2.2.0
9
+ torchaudio==2.2.0
uploads/bomdia_converted_only.wav ADDED
Binary file (35.6 kB). View file
 
venv/bin/Activate.ps1 ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <#
2
+ .Synopsis
3
+ Activate a Python virtual environment for the current PowerShell session.
4
+
5
+ .Description
6
+ Pushes the python executable for a virtual environment to the front of the
7
+ $Env:PATH environment variable and sets the prompt to signify that you are
8
+ in a Python virtual environment. Makes use of the command line switches as
9
+ well as the `pyvenv.cfg` file values present in the virtual environment.
10
+
11
+ .Parameter VenvDir
12
+ Path to the directory that contains the virtual environment to activate. The
13
+ default value for this is the parent of the directory that the Activate.ps1
14
+ script is located within.
15
+
16
+ .Parameter Prompt
17
+ The prompt prefix to display when this virtual environment is activated. By
18
+ default, this prompt is the name of the virtual environment folder (VenvDir)
19
+ surrounded by parentheses and followed by a single space (ie. '(.venv) ').
20
+
21
+ .Example
22
+ Activate.ps1
23
+ Activates the Python virtual environment that contains the Activate.ps1 script.
24
+
25
+ .Example
26
+ Activate.ps1 -Verbose
27
+ Activates the Python virtual environment that contains the Activate.ps1 script,
28
+ and shows extra information about the activation as it executes.
29
+
30
+ .Example
31
+ Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
32
+ Activates the Python virtual environment located in the specified location.
33
+
34
+ .Example
35
+ Activate.ps1 -Prompt "MyPython"
36
+ Activates the Python virtual environment that contains the Activate.ps1 script,
37
+ and prefixes the current prompt with the specified string (surrounded in
38
+ parentheses) while the virtual environment is active.
39
+
40
+ .Notes
41
+ On Windows, it may be required to enable this Activate.ps1 script by setting the
42
+ execution policy for the user. You can do this by issuing the following PowerShell
43
+ command:
44
+
45
+ PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
46
+
47
+ For more information on Execution Policies:
48
+ https://go.microsoft.com/fwlink/?LinkID=135170
49
+
50
+ #>
51
+ Param(
52
+ [Parameter(Mandatory = $false)]
53
+ [String]
54
+ $VenvDir,
55
+ [Parameter(Mandatory = $false)]
56
+ [String]
57
+ $Prompt
58
+ )
59
+
60
+ <# Function declarations --------------------------------------------------- #>
61
+
62
+ <#
63
+ .Synopsis
64
+ Remove all shell session elements added by the Activate script, including the
65
+ addition of the virtual environment's Python executable from the beginning of
66
+ the PATH variable.
67
+
68
+ .Parameter NonDestructive
69
+ If present, do not remove this function from the global namespace for the
70
+ session.
71
+
72
+ #>
73
+ function global:deactivate ([switch]$NonDestructive) {
74
+ # Revert to original values
75
+
76
+ # The prior prompt:
77
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
78
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
79
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
80
+ }
81
+
82
+ # The prior PYTHONHOME:
83
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
84
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
85
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
86
+ }
87
+
88
+ # The prior PATH:
89
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
90
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
91
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
92
+ }
93
+
94
+ # Just remove the VIRTUAL_ENV altogether:
95
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
96
+ Remove-Item -Path env:VIRTUAL_ENV
97
+ }
98
+
99
+ # Just remove VIRTUAL_ENV_PROMPT altogether.
100
+ if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
101
+ Remove-Item -Path env:VIRTUAL_ENV_PROMPT
102
+ }
103
+
104
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
105
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
106
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
107
+ }
108
+
109
+ # Leave deactivate function in the global namespace if requested:
110
+ if (-not $NonDestructive) {
111
+ Remove-Item -Path function:deactivate
112
+ }
113
+ }
114
+
115
+ <#
116
+ .Description
117
+ Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
118
+ given folder, and returns them in a map.
119
+
120
+ For each line in the pyvenv.cfg file, if that line can be parsed into exactly
121
+ two strings separated by `=` (with any amount of whitespace surrounding the =)
122
+ then it is considered a `key = value` line. The left hand string is the key,
123
+ the right hand is the value.
124
+
125
+ If the value starts with a `'` or a `"` then the first and last character is
126
+ stripped from the value before being captured.
127
+
128
+ .Parameter ConfigDir
129
+ Path to the directory that contains the `pyvenv.cfg` file.
130
+ #>
131
+ function Get-PyVenvConfig(
132
+ [String]
133
+ $ConfigDir
134
+ ) {
135
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
136
+
137
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
138
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
139
+
140
+ # An empty map will be returned if no config file is found.
141
+ $pyvenvConfig = @{ }
142
+
143
+ if ($pyvenvConfigPath) {
144
+
145
+ Write-Verbose "File exists, parse `key = value` lines"
146
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
147
+
148
+ $pyvenvConfigContent | ForEach-Object {
149
+ $keyval = $PSItem -split "\s*=\s*", 2
150
+ if ($keyval[0] -and $keyval[1]) {
151
+ $val = $keyval[1]
152
+
153
+ # Remove extraneous quotations around a string value.
154
+ if ("'""".Contains($val.Substring(0, 1))) {
155
+ $val = $val.Substring(1, $val.Length - 2)
156
+ }
157
+
158
+ $pyvenvConfig[$keyval[0]] = $val
159
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
160
+ }
161
+ }
162
+ }
163
+ return $pyvenvConfig
164
+ }
165
+
166
+
167
+ <# Begin Activate script --------------------------------------------------- #>
168
+
169
+ # Determine the containing directory of this script
170
+ $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
171
+ $VenvExecDir = Get-Item -Path $VenvExecPath
172
+
173
+ Write-Verbose "Activation script is located in path: '$VenvExecPath'"
174
+ Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
175
+ Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
176
+
177
+ # Set values required in priority: CmdLine, ConfigFile, Default
178
+ # First, get the location of the virtual environment, it might not be
179
+ # VenvExecDir if specified on the command line.
180
+ if ($VenvDir) {
181
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
182
+ }
183
+ else {
184
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
185
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
186
+ Write-Verbose "VenvDir=$VenvDir"
187
+ }
188
+
189
+ # Next, read the `pyvenv.cfg` file to determine any required value such
190
+ # as `prompt`.
191
+ $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
192
+
193
+ # Next, set the prompt from the command line, or the config file, or
194
+ # just use the name of the virtual environment folder.
195
+ if ($Prompt) {
196
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
197
+ }
198
+ else {
199
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
200
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
201
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
202
+ $Prompt = $pyvenvCfg['prompt'];
203
+ }
204
+ else {
205
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
206
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
207
+ $Prompt = Split-Path -Path $venvDir -Leaf
208
+ }
209
+ }
210
+
211
+ Write-Verbose "Prompt = '$Prompt'"
212
+ Write-Verbose "VenvDir='$VenvDir'"
213
+
214
+ # Deactivate any currently active virtual environment, but leave the
215
+ # deactivate function in place.
216
+ deactivate -nondestructive
217
+
218
+ # Now set the environment variable VIRTUAL_ENV, used by many tools to determine
219
+ # that there is an activated venv.
220
+ $env:VIRTUAL_ENV = $VenvDir
221
+
222
+ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
223
+
224
+ Write-Verbose "Setting prompt to '$Prompt'"
225
+
226
+ # Set the prompt to include the env name
227
+ # Make sure _OLD_VIRTUAL_PROMPT is global
228
+ function global:_OLD_VIRTUAL_PROMPT { "" }
229
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
230
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
231
+
232
+ function global:prompt {
233
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
234
+ _OLD_VIRTUAL_PROMPT
235
+ }
236
+ $env:VIRTUAL_ENV_PROMPT = $Prompt
237
+ }
238
+
239
+ # Clear PYTHONHOME
240
+ if (Test-Path -Path Env:PYTHONHOME) {
241
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
242
+ Remove-Item -Path Env:PYTHONHOME
243
+ }
244
+
245
+ # Add the venv to the PATH
246
+ Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
247
+ $Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
venv/bin/__pycache__/align_wordlists.cpython-312.pyc ADDED
Binary file (4.62 kB). View file
 
venv/bin/__pycache__/generate_ipa_all.cpython-312.pyc ADDED
Binary file (9.98 kB). View file
 
venv/bin/__pycache__/validate_ipa.cpython-312.pyc ADDED
Binary file (2.74 kB). View file
 
venv/bin/activate ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate" *from bash*
2
+ # You cannot run it directly
3
+
4
+ deactivate () {
5
+ # reset old environment variables
6
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7
+ PATH="${_OLD_VIRTUAL_PATH:-}"
8
+ export PATH
9
+ unset _OLD_VIRTUAL_PATH
10
+ fi
11
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13
+ export PYTHONHOME
14
+ unset _OLD_VIRTUAL_PYTHONHOME
15
+ fi
16
+
17
+ # Call hash to forget past locations. Without forgetting
18
+ # past locations the $PATH changes we made may not be respected.
19
+ # See "man bash" for more details. hash is usually a builtin of your shell
20
+ hash -r 2> /dev/null
21
+
22
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
23
+ PS1="${_OLD_VIRTUAL_PS1:-}"
24
+ export PS1
25
+ unset _OLD_VIRTUAL_PS1
26
+ fi
27
+
28
+ unset VIRTUAL_ENV
29
+ unset VIRTUAL_ENV_PROMPT
30
+ if [ ! "${1:-}" = "nondestructive" ] ; then
31
+ # Self destruct!
32
+ unset -f deactivate
33
+ fi
34
+ }
35
+
36
+ # unset irrelevant variables
37
+ deactivate nondestructive
38
+
39
+ # on Windows, a path can contain colons and backslashes and has to be converted:
40
+ if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
41
+ # transform D:\path\to\venv to /d/path/to/venv on MSYS
42
+ # and to /cygdrive/d/path/to/venv on Cygwin
43
+ export VIRTUAL_ENV=$(cygpath /Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv)
44
+ else
45
+ # use the path as-is
46
+ export VIRTUAL_ENV=/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv
47
+ fi
48
+
49
+ _OLD_VIRTUAL_PATH="$PATH"
50
+ PATH="$VIRTUAL_ENV/"bin":$PATH"
51
+ export PATH
52
+
53
+ # unset PYTHONHOME if set
54
+ # this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
55
+ # could use `if (set -u; : $PYTHONHOME) ;` in bash
56
+ if [ -n "${PYTHONHOME:-}" ] ; then
57
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
58
+ unset PYTHONHOME
59
+ fi
60
+
61
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
62
+ _OLD_VIRTUAL_PS1="${PS1:-}"
63
+ PS1='(venv) '"${PS1:-}"
64
+ export PS1
65
+ VIRTUAL_ENV_PROMPT='(venv) '
66
+ export VIRTUAL_ENV_PROMPT
67
+ fi
68
+
69
+ # Call hash to forget past commands. Without forgetting
70
+ # past commands the $PATH changes we made may not be respected
71
+ hash -r 2> /dev/null
venv/bin/activate.csh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate.csh" *from csh*.
2
+ # You cannot run it directly.
3
+
4
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
5
+ # Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
6
+
7
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
8
+
9
+ # Unset irrelevant variables.
10
+ deactivate nondestructive
11
+
12
+ setenv VIRTUAL_ENV /Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv
13
+
14
+ set _OLD_VIRTUAL_PATH="$PATH"
15
+ setenv PATH "$VIRTUAL_ENV/"bin":$PATH"
16
+
17
+
18
+ set _OLD_VIRTUAL_PROMPT="$prompt"
19
+
20
+ if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
21
+ set prompt = '(venv) '"$prompt"
22
+ setenv VIRTUAL_ENV_PROMPT '(venv) '
23
+ endif
24
+
25
+ alias pydoc python -m pydoc
26
+
27
+ rehash
venv/bin/activate.fish ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source <venv>/bin/activate.fish" *from fish*
2
+ # (https://fishshell.com/). You cannot run it directly.
3
+
4
+ function deactivate -d "Exit virtual environment and return to normal shell environment"
5
+ # reset old environment variables
6
+ if test -n "$_OLD_VIRTUAL_PATH"
7
+ set -gx PATH $_OLD_VIRTUAL_PATH
8
+ set -e _OLD_VIRTUAL_PATH
9
+ end
10
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12
+ set -e _OLD_VIRTUAL_PYTHONHOME
13
+ end
14
+
15
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16
+ set -e _OLD_FISH_PROMPT_OVERRIDE
17
+ # prevents error when using nested fish instances (Issue #93858)
18
+ if functions -q _old_fish_prompt
19
+ functions -e fish_prompt
20
+ functions -c _old_fish_prompt fish_prompt
21
+ functions -e _old_fish_prompt
22
+ end
23
+ end
24
+
25
+ set -e VIRTUAL_ENV
26
+ set -e VIRTUAL_ENV_PROMPT
27
+ if test "$argv[1]" != "nondestructive"
28
+ # Self-destruct!
29
+ functions -e deactivate
30
+ end
31
+ end
32
+
33
+ # Unset irrelevant variables.
34
+ deactivate nondestructive
35
+
36
+ set -gx VIRTUAL_ENV /Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv
37
+
38
+ set -gx _OLD_VIRTUAL_PATH $PATH
39
+ set -gx PATH "$VIRTUAL_ENV/"bin $PATH
40
+
41
+ # Unset PYTHONHOME if set.
42
+ if set -q PYTHONHOME
43
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
44
+ set -e PYTHONHOME
45
+ end
46
+
47
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
48
+ # fish uses a function instead of an env var to generate the prompt.
49
+
50
+ # Save the current fish_prompt function as the function _old_fish_prompt.
51
+ functions -c fish_prompt _old_fish_prompt
52
+
53
+ # With the original prompt function renamed, we can override with our own.
54
+ function fish_prompt
55
+ # Save the return status of the last command.
56
+ set -l old_status $status
57
+
58
+ # Output the venv prompt; color taken from the blue of the Python logo.
59
+ printf "%s%s%s" (set_color 4B8BBE) '(venv) ' (set_color normal)
60
+
61
+ # Restore the return status of the previous command.
62
+ echo "exit $old_status" | .
63
+ # Output the original/"old" prompt.
64
+ _old_fish_prompt
65
+ end
66
+
67
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
68
+ set -gx VIRTUAL_ENV_PROMPT '(venv) '
69
+ end
venv/bin/align_wordlists.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ from __future__ import print_function
3
+
4
+ import unicodecsv as csv
5
+ import argparse
6
+ import panphon
7
+ import Levenshtein
8
+ import munkres
9
+ import panphon.distance
10
+ from functools import partial
11
+
12
+
13
+ def levenshtein_dist(_, a, b):
14
+ return Levenshtein.distance(a, b)
15
+
16
+
17
+ def dogol_leven_dist(_, a, b):
18
+ return Levenshtein.distance(dist.map_to_dogol_prime(a),
19
+ dist.map_to_dogol_prime(b))
20
+
21
+
22
+ def feature_hamming_dist(dist, a, b):
23
+ return dist.feature_edit_distance(a, b)
24
+
25
+
26
+ def feature_weighted_dist(dist, a, b):
27
+ return dist.weighted_feature_edit_distance(a, b)
28
+
29
+
30
+ def construct_cost_matrix(words_a, words_b, dist):
31
+ def matrix_row(word_a, words_b):
32
+ return [dist(word_a, word_b) for (word_b, _) in words_b]
33
+ return [matrix_row(word_a, words_b) for (word_a, _) in words_a]
34
+
35
+
36
+ def score(indices):
37
+ pairs, errors = 0, 0
38
+ for row, column in indices:
39
+ pairs += 1
40
+ if row != column:
41
+ errors += 1
42
+ return pairs, errors
43
+
44
+
45
+ def main(wordlist1, wordlist2, dist_funcs):
46
+ with open(wordlist1, 'rb') as file_a, open(wordlist2, 'rb') as file_b:
47
+ reader_a = csv.reader(file_a, encoding='utf-8')
48
+ reader_b = csv.reader(file_b, encoding='utf-8')
49
+ print('Reading word lists...')
50
+ words = zip([(w, g) for (g, w) in reader_a],
51
+ [(w, g) for (g, w) in reader_b])
52
+ words_a, words_b = zip(*[(a, b) for (a, b) in words if a and b])
53
+ print('Constructing cost matrix...')
54
+ matrix = construct_cost_matrix(words_a, words_b, dist_funcs)
55
+ m = munkres.Munkres()
56
+ print('Computing matrix using Hungarian Algorithm...')
57
+ indices = m.compute(matrix)
58
+ print(score(indices))
59
+ print('Done.')
60
+
61
+
62
+ if __name__ == '__main__':
63
+ parser = argparse.ArgumentParser(usage='Align two lists of "cognates" using a specified distance metric.')
64
+ parser.add_argument('wordlists', nargs=2, help='Filenames of two wordlists in corresponding order.')
65
+ parser.add_argument('-d', '--dist', default='hamming', help='Distance metric (e.g. Hamming).')
66
+ args = parser.parse_args()
67
+ dists = {'levenshtein': levenshtein_dist,
68
+ 'dogol-leven': dogol_leven_dist,
69
+ 'hamming': feature_hamming_dist,
70
+ 'weighted': feature_weighted_dist}
71
+ dist = panphon.distance.Distance()
72
+ dist_funcs = partial(dists[args.dist], dist)
73
+ main(args.wordlists[0], args.wordlists[1], dist_funcs)
venv/bin/convert-caffe2-to-onnx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from caffe2.python.onnx.bin.conversion import caffe2_to_onnx
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(caffe2_to_onnx())
venv/bin/convert-onnx-to-caffe2 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from caffe2.python.onnx.bin.conversion import onnx_to_caffe2
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(onnx_to_caffe2())
venv/bin/dotenv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from dotenv.cli import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
venv/bin/f2py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from numpy.f2py.f2py2e import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/flask ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from flask.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/generate_ipa_all.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ from __future__ import print_function, unicode_literals
3
+
4
+ import argparse
5
+ import codecs
6
+ import copy
7
+
8
+ import yaml
9
+
10
+ import unicodecsv as csv
11
+
12
+
13
+ class Segment(object):
14
+ """Class modeling phonological segment."""
15
+
16
+ def __init__(self, form, features):
17
+ """Construct Segment objectself.
18
+
19
+ Args:
20
+ form (string): the segment as ipa
21
+ features (list): the segment as feature_names
22
+ """
23
+ self.form = form
24
+ self.features = features
25
+
26
+ def __repr__(self):
27
+ """Output string representation of Segment."""
28
+ return 'Segment("{}", {})'.format(self.form,
29
+ repr(self.features)).encode('utf-8')
30
+
31
+ def feature_vector(self, feature_names):
32
+ """Return feature vector for segment.
33
+
34
+ Args:
35
+ feature_names (list): ordered names of features
36
+
37
+ Returns:
38
+ list: feature values
39
+ """
40
+ return [self.features[ft] for ft in feature_names]
41
+
42
+
43
+ class Diacritic(object):
44
+ """An object encapsulating a diacritics properties."""
45
+
46
+ def __init__(self, marker, position, conditions, exclude, content):
47
+ """Construct a diacritic object.
48
+
49
+ Args:
50
+ marker (unicode): the string form of the diacritic
51
+ position (str): 'pre' or 'post', determining whether the diacritic
52
+ attaches before or after the base
53
+ conditions (list): feature specification on which application of
54
+ diacritic is conditional
55
+ exclude (list): conditions under which the diacritic will not be
56
+ applied]
57
+ content (list): feature specification that will override
58
+ existing feature specifications when diacritics
59
+ is applied
60
+ """
61
+ self.marker = marker
62
+ assert position in ['pre', 'post']
63
+ self.position = position
64
+ self.exclude = exclude
65
+ self.conditions = conditions
66
+ self.content = content
67
+
68
+ def match(self, segment):
69
+ if segment.form not in self.exclude:
70
+ for condition in self.conditions:
71
+ if set(condition.items()) <= set(segment.features.items()):
72
+ return True
73
+ return False
74
+ else:
75
+ return False
76
+
77
+ def apply(self, segment):
78
+ if self.match(segment):
79
+ new_seg = copy.deepcopy(segment)
80
+ for k, v in self.content.items():
81
+ new_seg.features[k] = v
82
+ if self.position == 'post':
83
+ new_seg.form = '{}{}'.format(new_seg.form, self.marker)
84
+ else:
85
+ new_seg.form = '{}{}'.format(self.marker, new_seg.form)
86
+ return new_seg
87
+ else:
88
+ return None
89
+
90
+
91
+ class Combination(object):
92
+ def __init__(self, diacritics, name, sequence):
93
+ self.name = name
94
+ self.sequence = [diacritics[d] for d in sequence]
95
+
96
+ def apply(self, segment):
97
+ new_seg = copy.deepcopy(segment)
98
+ for dia in self.sequence:
99
+ if dia.match(new_seg):
100
+ new_seg = dia.apply(new_seg)
101
+ else:
102
+ return None
103
+ return new_seg
104
+
105
+
106
+ def read_ipa_bases(ipa_bases):
107
+ segments = []
108
+ with open(ipa_bases, 'rb') as f:
109
+ dictreader = csv.DictReader(f, encoding='utf=8')
110
+ for record in dictreader:
111
+ form = record['ipa']
112
+ features = {k: v for k, v in record.items() if k != 'ipa'}
113
+ segments.append(Segment(form, features))
114
+ return segments
115
+
116
+
117
+ def parse_dia_defs(dia_defs):
118
+ defs = yaml.load(codecs.open(dia_defs, "r", "utf-8").read(), Loader=yaml.FullLoader)
119
+ diacritics = {}
120
+ for dia in defs['diacritics']:
121
+ if 'exclude' in dia:
122
+ exclude = dia['exclude']
123
+ else:
124
+ exclude = []
125
+ diacritics[dia['name']] = Diacritic(dia['marker'], dia['position'],
126
+ dia['conditions'], exclude,
127
+ dia['content'])
128
+ combinations = []
129
+ for comb in defs['combinations']:
130
+ combinations.append(Combination(diacritics, comb['name'],
131
+ comb['combines']))
132
+ return diacritics, combinations
133
+
134
+
135
+ def sort_all_segments(sort_order, all_segments):
136
+ all_segments_list = list(all_segments)
137
+ field_order = reversed(yaml.load(open(sort_order, 'r').read(), Loader=yaml.FullLoader))
138
+ for field in field_order:
139
+ all_segments_list.sort(key=lambda seg: seg.features[field['name']],
140
+ reverse=field['reverse'])
141
+ return all_segments_list
142
+
143
+
144
+ def write_ipa_all(ipa_bases, ipa_all, all_segments, sort_order):
145
+ with open(ipa_bases, 'rb') as f:
146
+ reader = csv.reader(f, encoding='utf-8')
147
+ fieldnames = next(reader)
148
+ with open(ipa_all, 'wb') as f:
149
+ writer = csv.DictWriter(f, encoding='utf-8', fieldnames=fieldnames)
150
+ writer.writerow({k: k for k in fieldnames})
151
+ all_segments_list = sort_all_segments(sort_order, all_segments)
152
+ for segment in all_segments_list:
153
+ fields = copy.copy(segment.features)
154
+ fields['ipa'] = segment.form
155
+ writer.writerow(fields)
156
+
157
+
158
+ def main(ipa_bases, ipa_all, dia_defs, sort_order):
159
+ segments = read_ipa_bases(ipa_bases)
160
+ diacritics, combinations = parse_dia_defs(dia_defs)
161
+ all_segments = set(segments)
162
+ for diacritic in diacritics.values():
163
+ for segment in segments:
164
+ new_seg = diacritic.apply(segment)
165
+ if new_seg is not None:
166
+ all_segments.add(new_seg)
167
+ for combination in combinations:
168
+ for segment in segments:
169
+ new_seg = combination.apply(segment)
170
+ if new_seg is not None:
171
+ all_segments.add(new_seg)
172
+ write_ipa_all(ipa_bases, ipa_all, all_segments, sort_order)
173
+
174
+
175
+ if __name__ == '__main__':
176
+ parser = argparse.ArgumentParser()
177
+ parser.add_argument('bases', help='File containing IPA bases (ipa_bases.csv)')
178
+ parser.add_argument('all', help='File to which all IPA segments is to be written (ipa_all.csv)')
179
+ parser.add_argument('-d', '--dia', required=True, help='Diacritic definition file (default=diacritic_definitions.yml)')
180
+ parser.add_argument('-s', '--sort-order', required=True, help='File definiting sort order.')
181
+ args = parser.parse_args()
182
+ main(args.bases, args.all, args.dia, args.sort_order)
venv/bin/isympy ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from isympy import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/normalizer ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from charset_normalizer.cli.normalizer import cli_detect
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli_detect())
venv/bin/numba ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: UTF-8 -*-
3
+ from __future__ import print_function, division, absolute_import
4
+
5
+ from numba.misc.numba_entry import main
6
+
7
+ if __name__ == "__main__":
8
+ main()
venv/bin/pip ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/pip3 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/pip3.12 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/python ADDED
@@ -0,0 +1 @@
 
 
1
+ python3.12
venv/bin/python3 ADDED
@@ -0,0 +1 @@
 
 
1
+ python3.12
venv/bin/python3.12 ADDED
@@ -0,0 +1 @@
 
 
1
+ /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
venv/bin/torchrun ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from torch.distributed.run import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/validate_ipa.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3.12
2
+ # -*- coding: utf-8 -*-
3
+ from __future__ import print_function
4
+ from __future__ import unicode_literals
5
+
6
+ import panphon
7
+ import regex as re
8
+ import sys
9
+
10
+
11
+ class Validator(object):
12
+ def __init__(self, infile=sys.stdin):
13
+ """Validate Unicode IPA from file relative to panphon database.
14
+
15
+ infile -- File from which input is taken; by default, STDIN.
16
+ """
17
+ self.ws_punc_regex = re.compile(r'[," \t\n]', re.V1 | re.U)
18
+ self.ft = panphon.FeatureTable()
19
+ self._validate_file(infile)
20
+
21
+ def _validate_file(self, infile):
22
+ for line in infile:
23
+ line = unicode(line, 'utf-8')
24
+ self.validate_line(line)
25
+
26
+ def validate_line(self, line):
27
+ """Validate Unicode IPA string relative to panphon.
28
+
29
+ line -- String of IPA characters. Can contain whitespace and limited
30
+ punctuation.
31
+ """
32
+ line0 = line
33
+ pos = 0
34
+ while line:
35
+ seg_m = self.ft.seg_regex.match(line)
36
+ wsp_m = self.ws_punc_regex.match(line)
37
+ if seg_m:
38
+ length = len(seg_m.group(0))
39
+ line = line[length:]
40
+ pos += length
41
+ elif wsp_m:
42
+ length = len(wsp_m.group(0))
43
+ line = line[length:]
44
+ pos += length
45
+ else:
46
+ msg = 'IPA not valid at position {} in "{}".'.format(pos, line0.strip())
47
+ # msg = msg.decode('utf-8')
48
+ print(msg, file=sys.stderr)
49
+ line = line[1:]
50
+ pos += 1
51
+
52
+
53
+ if __name__ == '__main__':
54
+ validator = Validator(sys.stdin)
venv/pyvenv.cfg ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ home = /Library/Frameworks/Python.framework/Versions/3.12/bin
2
+ include-system-site-packages = false
3
+ version = 3.12.8
4
+ executable = /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
5
+ command = /Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv/bin/python3 -m venv /Users/marcos/Documents/projects/parle/avataronly/avatar_v10/avatar2b/backend/servers/allosaurus/lipsync/venv
venv/share/man/man1/isympy.1 ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '\" -*- coding: us-ascii -*-
2
+ .if \n(.g .ds T< \\FC
3
+ .if \n(.g .ds T> \\F[\n[.fam]]
4
+ .de URL
5
+ \\$2 \(la\\$1\(ra\\$3
6
+ ..
7
+ .if \n(.g .mso www.tmac
8
+ .TH isympy 1 2007-10-8 "" ""
9
+ .SH NAME
10
+ isympy \- interactive shell for SymPy
11
+ .SH SYNOPSIS
12
+ 'nh
13
+ .fi
14
+ .ad l
15
+ \fBisympy\fR \kx
16
+ .if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
17
+ 'in \n(.iu+\nxu
18
+ [\fB-c\fR | \fB--console\fR] [\fB-p\fR ENCODING | \fB--pretty\fR ENCODING] [\fB-t\fR TYPE | \fB--types\fR TYPE] [\fB-o\fR ORDER | \fB--order\fR ORDER] [\fB-q\fR | \fB--quiet\fR] [\fB-d\fR | \fB--doctest\fR] [\fB-C\fR | \fB--no-cache\fR] [\fB-a\fR | \fB--auto\fR] [\fB-D\fR | \fB--debug\fR] [
19
+ -- | PYTHONOPTIONS]
20
+ 'in \n(.iu-\nxu
21
+ .ad b
22
+ 'hy
23
+ 'nh
24
+ .fi
25
+ .ad l
26
+ \fBisympy\fR \kx
27
+ .if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
28
+ 'in \n(.iu+\nxu
29
+ [
30
+ {\fB-h\fR | \fB--help\fR}
31
+ |
32
+ {\fB-v\fR | \fB--version\fR}
33
+ ]
34
+ 'in \n(.iu-\nxu
35
+ .ad b
36
+ 'hy
37
+ .SH DESCRIPTION
38
+ isympy is a Python shell for SymPy. It is just a normal python shell
39
+ (ipython shell if you have the ipython package installed) that executes
40
+ the following commands so that you don't have to:
41
+ .PP
42
+ .nf
43
+ \*(T<
44
+ >>> from __future__ import division
45
+ >>> from sympy import *
46
+ >>> x, y, z = symbols("x,y,z")
47
+ >>> k, m, n = symbols("k,m,n", integer=True)
48
+ \*(T>
49
+ .fi
50
+ .PP
51
+ So starting isympy is equivalent to starting python (or ipython) and
52
+ executing the above commands by hand. It is intended for easy and quick
53
+ experimentation with SymPy. For more complicated programs, it is recommended
54
+ to write a script and import things explicitly (using the "from sympy
55
+ import sin, log, Symbol, ..." idiom).
56
+ .SH OPTIONS
57
+ .TP
58
+ \*(T<\fB\-c \fR\*(T>\fISHELL\fR, \*(T<\fB\-\-console=\fR\*(T>\fISHELL\fR
59
+ Use the specified shell (python or ipython) as
60
+ console backend instead of the default one (ipython
61
+ if present or python otherwise).
62
+
63
+ Example: isympy -c python
64
+
65
+ \fISHELL\fR could be either
66
+ \&'ipython' or 'python'
67
+ .TP
68
+ \*(T<\fB\-p \fR\*(T>\fIENCODING\fR, \*(T<\fB\-\-pretty=\fR\*(T>\fIENCODING\fR
69
+ Setup pretty printing in SymPy. By default, the most pretty, unicode
70
+ printing is enabled (if the terminal supports it). You can use less
71
+ pretty ASCII printing instead or no pretty printing at all.
72
+
73
+ Example: isympy -p no
74
+
75
+ \fIENCODING\fR must be one of 'unicode',
76
+ \&'ascii' or 'no'.
77
+ .TP
78
+ \*(T<\fB\-t \fR\*(T>\fITYPE\fR, \*(T<\fB\-\-types=\fR\*(T>\fITYPE\fR
79
+ Setup the ground types for the polys. By default, gmpy ground types
80
+ are used if gmpy2 or gmpy is installed, otherwise it falls back to python
81
+ ground types, which are a little bit slower. You can manually
82
+ choose python ground types even if gmpy is installed (e.g., for testing purposes).
83
+
84
+ Note that sympy ground types are not supported, and should be used
85
+ only for experimental purposes.
86
+
87
+ Note that the gmpy1 ground type is primarily intended for testing; it the
88
+ use of gmpy even if gmpy2 is available.
89
+
90
+ This is the same as setting the environment variable
91
+ SYMPY_GROUND_TYPES to the given ground type (e.g.,
92
+ SYMPY_GROUND_TYPES='gmpy')
93
+
94
+ The ground types can be determined interactively from the variable
95
+ sympy.polys.domains.GROUND_TYPES inside the isympy shell itself.
96
+
97
+ Example: isympy -t python
98
+
99
+ \fITYPE\fR must be one of 'gmpy',
100
+ \&'gmpy1' or 'python'.
101
+ .TP
102
+ \*(T<\fB\-o \fR\*(T>\fIORDER\fR, \*(T<\fB\-\-order=\fR\*(T>\fIORDER\fR
103
+ Setup the ordering of terms for printing. The default is lex, which
104
+ orders terms lexicographically (e.g., x**2 + x + 1). You can choose
105
+ other orderings, such as rev-lex, which will use reverse
106
+ lexicographic ordering (e.g., 1 + x + x**2).
107
+
108
+ Note that for very large expressions, ORDER='none' may speed up
109
+ printing considerably, with the tradeoff that the order of the terms
110
+ in the printed expression will have no canonical order
111
+
112
+ Example: isympy -o rev-lax
113
+
114
+ \fIORDER\fR must be one of 'lex', 'rev-lex', 'grlex',
115
+ \&'rev-grlex', 'grevlex', 'rev-grevlex', 'old', or 'none'.
116
+ .TP
117
+ \*(T<\fB\-q\fR\*(T>, \*(T<\fB\-\-quiet\fR\*(T>
118
+ Print only Python's and SymPy's versions to stdout at startup, and nothing else.
119
+ .TP
120
+ \*(T<\fB\-d\fR\*(T>, \*(T<\fB\-\-doctest\fR\*(T>
121
+ Use the same format that should be used for doctests. This is
122
+ equivalent to '\fIisympy -c python -p no\fR'.
123
+ .TP
124
+ \*(T<\fB\-C\fR\*(T>, \*(T<\fB\-\-no\-cache\fR\*(T>
125
+ Disable the caching mechanism. Disabling the cache may slow certain
126
+ operations down considerably. This is useful for testing the cache,
127
+ or for benchmarking, as the cache can result in deceptive benchmark timings.
128
+
129
+ This is the same as setting the environment variable SYMPY_USE_CACHE
130
+ to 'no'.
131
+ .TP
132
+ \*(T<\fB\-a\fR\*(T>, \*(T<\fB\-\-auto\fR\*(T>
133
+ Automatically create missing symbols. Normally, typing a name of a
134
+ Symbol that has not been instantiated first would raise NameError,
135
+ but with this option enabled, any undefined name will be
136
+ automatically created as a Symbol. This only works in IPython 0.11.
137
+
138
+ Note that this is intended only for interactive, calculator style
139
+ usage. In a script that uses SymPy, Symbols should be instantiated
140
+ at the top, so that it's clear what they are.
141
+
142
+ This will not override any names that are already defined, which
143
+ includes the single character letters represented by the mnemonic
144
+ QCOSINE (see the "Gotchas and Pitfalls" document in the
145
+ documentation). You can delete existing names by executing "del
146
+ name" in the shell itself. You can see if a name is defined by typing
147
+ "'name' in globals()".
148
+
149
+ The Symbols that are created using this have default assumptions.
150
+ If you want to place assumptions on symbols, you should create them
151
+ using symbols() or var().
152
+
153
+ Finally, this only works in the top level namespace. So, for
154
+ example, if you define a function in isympy with an undefined
155
+ Symbol, it will not work.
156
+ .TP
157
+ \*(T<\fB\-D\fR\*(T>, \*(T<\fB\-\-debug\fR\*(T>
158
+ Enable debugging output. This is the same as setting the
159
+ environment variable SYMPY_DEBUG to 'True'. The debug status is set
160
+ in the variable SYMPY_DEBUG within isympy.
161
+ .TP
162
+ -- \fIPYTHONOPTIONS\fR
163
+ These options will be passed on to \fIipython (1)\fR shell.
164
+ Only supported when ipython is being used (standard python shell not supported).
165
+
166
+ Two dashes (--) are required to separate \fIPYTHONOPTIONS\fR
167
+ from the other isympy options.
168
+
169
+ For example, to run iSymPy without startup banner and colors:
170
+
171
+ isympy -q -c ipython -- --colors=NoColor
172
+ .TP
173
+ \*(T<\fB\-h\fR\*(T>, \*(T<\fB\-\-help\fR\*(T>
174
+ Print help output and exit.
175
+ .TP
176
+ \*(T<\fB\-v\fR\*(T>, \*(T<\fB\-\-version\fR\*(T>
177
+ Print isympy version information and exit.
178
+ .SH FILES
179
+ .TP
180
+ \*(T<\fI${HOME}/.sympy\-history\fR\*(T>
181
+ Saves the history of commands when using the python
182
+ shell as backend.
183
+ .SH BUGS
184
+ The upstreams BTS can be found at \(lahttps://github.com/sympy/sympy/issues\(ra
185
+ Please report all bugs that you find in there, this will help improve
186
+ the overall quality of SymPy.
187
+ .SH "SEE ALSO"
188
+ \fBipython\fR(1), \fBpython\fR(1)