Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -176,6 +176,14 @@ def analyze_audio(audio_file: str,
|
|
| 176 |
ends: List[float] = []
|
| 177 |
rows: List[Dict[str, Any]] = []
|
| 178 |
rawTranscriptionText: str = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
if not os.path.exists(audio_file):
|
| 180 |
results.message = f"Error: Input audio file '{audio_file}' not found."
|
| 181 |
return results
|
|
|
|
| 176 |
ends: List[float] = []
|
| 177 |
rows: List[Dict[str, Any]] = []
|
| 178 |
rawTranscriptionText: str = ""
|
| 179 |
+
if device == "cpu":
|
| 180 |
+
num_cores = os.cpu_count() or 4
|
| 181 |
+
print(f"Setting PyTorch threads to {num_cores} for CPU performance optimization.")
|
| 182 |
+
try:
|
| 183 |
+
torch.set_num_threads(num_cores)
|
| 184 |
+
torch.jit.enable_onednn_fusion(True)
|
| 185 |
+
except Exception as e:
|
| 186 |
+
print(f"Warning: Failed to set PyTorch performance flags: {e}")
|
| 187 |
if not os.path.exists(audio_file):
|
| 188 |
results.message = f"Error: Input audio file '{audio_file}' not found."
|
| 189 |
return results
|