Spaces:
Runtime error
Runtime error
Peter Michael Gits Claude commited on
Commit Β·
b8737d8
1
Parent(s): 1a1d398
Add comprehensive LMGen debugging and introspection
Browse filesv1.4.9 - Deep debug LMGen step() returning None:
- Added LMGen type and methods introspection
- Test step() with and without streaming context
- Log LMGen internal state and attributes
- Try different approaches to find working API pattern
- Will reveal why step() returns None and correct usage
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -21,7 +21,7 @@ from fastapi.responses import JSONResponse, HTMLResponse
|
|
| 21 |
import uvicorn
|
| 22 |
|
| 23 |
# Version tracking
|
| 24 |
-
VERSION = "1.4.
|
| 25 |
COMMIT_SHA = "TBD"
|
| 26 |
|
| 27 |
# Configure logging
|
|
@@ -176,35 +176,36 @@ def transcribe_audio_moshi(audio_data: np.ndarray, sample_rate: int = 24000) ->
|
|
| 176 |
try:
|
| 177 |
# Use the actual language model for generation
|
| 178 |
if lm_gen and lm_gen != "mock":
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
if text_tokens:
|
| 203 |
-
all_text_tokens = torch.cat(text_tokens, dim=-1)
|
| 204 |
-
text_output = f"Moshiko CPU transcription: Generated {all_text_tokens.shape} text tokens"
|
| 205 |
-
logger.info(f"β
Generated transcription: {text_output}")
|
| 206 |
else:
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
else:
|
| 209 |
text_output = "Moshiko fallback: LM generator not available"
|
| 210 |
logger.warning("β οΈ LM generator not available, using fallback")
|
|
|
|
| 21 |
import uvicorn
|
| 22 |
|
| 23 |
# Version tracking
|
| 24 |
+
VERSION = "1.4.9"
|
| 25 |
COMMIT_SHA = "TBD"
|
| 26 |
|
| 27 |
# Configure logging
|
|
|
|
| 176 |
try:
|
| 177 |
# Use the actual language model for generation
|
| 178 |
if lm_gen and lm_gen != "mock":
|
| 179 |
+
logger.info(f"π§ LMGen type: {type(lm_gen)}")
|
| 180 |
+
logger.info(f"π§ LMGen methods: {[m for m in dir(lm_gen) if not m.startswith('_')]}")
|
| 181 |
+
|
| 182 |
+
# Try simpler approach - maybe streaming context is the issue
|
| 183 |
+
try:
|
| 184 |
+
# First try without streaming context
|
| 185 |
+
logger.info("π§ͺ Trying step() without streaming context...")
|
| 186 |
+
code_step = audio_tokens[:, :, 0:1] # Just first timestep [B, 8, 1]
|
| 187 |
+
tokens_out = lm_gen.step(code_step)
|
| 188 |
+
logger.info(f"π Direct step result: {type(tokens_out)}, value: {tokens_out}")
|
| 189 |
+
|
| 190 |
+
if tokens_out is None:
|
| 191 |
+
# Try with streaming context
|
| 192 |
+
logger.info("π§ͺ Trying with streaming context...")
|
| 193 |
+
with lm_gen.streaming(1):
|
| 194 |
+
tokens_out = lm_gen.step(code_step)
|
| 195 |
+
logger.info(f"π Streaming step result: {type(tokens_out)}, value: {tokens_out}")
|
| 196 |
+
|
| 197 |
+
if tokens_out is None:
|
| 198 |
+
# Maybe we need to call a different method or check state
|
| 199 |
+
logger.error("π¨ Both approaches returned None - checking LMGen state")
|
| 200 |
+
logger.info(f"π§ LMGen attributes: {vars(lm_gen) if hasattr(lm_gen, '__dict__') else 'No __dict__'}")
|
| 201 |
+
text_output = "Moshiko: LMGen step() returns None - API issue"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
else:
|
| 203 |
+
logger.info(f"β
Got tokens! Shape: {tokens_out.shape if hasattr(tokens_out, 'shape') else 'No shape'}")
|
| 204 |
+
text_output = f"Moshiko CPU: Successfully generated tokens with shape {tokens_out.shape if hasattr(tokens_out, 'shape') else 'unknown'}"
|
| 205 |
+
|
| 206 |
+
except Exception as step_error:
|
| 207 |
+
logger.error(f"π¨ LMGen step error: {step_error}")
|
| 208 |
+
text_output = f"Moshiko: LMGen step error: {str(step_error)}"
|
| 209 |
else:
|
| 210 |
text_output = "Moshiko fallback: LM generator not available"
|
| 211 |
logger.warning("β οΈ LM generator not available, using fallback")
|