Parimal Kalpande commited on
Commit
9753f0a
Β·
1 Parent(s): b97d99f

this is new update

Browse files
HF_DEPLOYMENT_CHECKLIST.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸš€ Hugging Face Deployment Checklist
2
+
3
+ ## βœ… Issues Fixed:
4
+
5
+ 1. **Added missing dependencies:**
6
+ - `python-dotenv` for environment variable loading
7
+ - Linux TTS support with `espeak`
8
+
9
+ 2. **Fixed import issues:**
10
+ - Changed `import regex as re` to `import re` (using standard library)
11
+ - Ensured all modules properly handle missing dependencies
12
+
13
+ 3. **Enhanced TTS support:**
14
+ - Added Linux `espeak` fallback for TTS
15
+ - Updated `packages.txt` with required system packages
16
+
17
+ 4. **Fixed directory creation:**
18
+ - Ensured upload and reports directories are created automatically
19
+
20
+ ## πŸ” Required Setup on Hugging Face:
21
+
22
+ 1. **Add Secret Variable:**
23
+ - Go to Space Settings β†’ Variables and secrets
24
+ - Add: `GROQ_API_KEY` = your_groq_api_key
25
+ - Get key from: https://console.groq.com/keys
26
+
27
+ ## πŸ“¦ Files Ready for Deployment:
28
+
29
+ - βœ… `app.py` - Main application
30
+ - βœ… `requirements.txt` - Python dependencies (fixed)
31
+ - βœ… `packages.txt` - System packages (enhanced)
32
+ - βœ… `README.md` - With proper HF header
33
+ - βœ… `config.py` - Configuration (improved)
34
+ - βœ… `modules/` - All module files
35
+ - βœ… `voice_model/` - TTS model files
36
+
37
+ ## 🚨 Common Runtime Errors & Solutions:
38
+
39
+ ### 1. "No module named 'dotenv'"
40
+ - **Fixed**: Added `python-dotenv` to requirements.txt
41
+
42
+ ### 2. "No module named 'regex'"
43
+ - **Fixed**: Changed to use standard `re` module
44
+
45
+ ### 3. TTS not working on Linux
46
+ - **Fixed**: Added espeak support and system packages
47
+
48
+ ### 4. "GROQ_API_KEY not found"
49
+ - **Solution**: Add as secret in HF Space settings
50
+
51
+ ### 5. Permission denied on file creation
52
+ - **Fixed**: Ensured directories are created in config.py
53
+
54
+ ## πŸš€ Deployment Steps:
55
+
56
+ 1. **Upload all files** to your Hugging Face Space
57
+ 2. **Add GROQ_API_KEY secret** in Space settings
58
+ 3. **Wait for build** to complete (5-10 minutes)
59
+ 4. **Test the app** - it should launch without errors
60
+
61
+ ## ⚠️ Known Limitations on HF:
62
+
63
+ - TTS quality may be lower on Linux (espeak vs macOS say)
64
+ - Large file uploads may be slower
65
+ - Some advanced audio features might have reduced performance
SECRETS_SETUP.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ” Hugging Face Secrets Configuration
2
+
3
+ To deploy this app successfully on Hugging Face Spaces, you need to configure the following secret:
4
+
5
+ ## Required Secret:
6
+
7
+ 1. **GROQ_API_KEY**
8
+ - Go to your Hugging Face Space settings
9
+ - Navigate to "Variables and secrets" section
10
+ - Add a new secret:
11
+ - Name: `GROQ_API_KEY`
12
+ - Value: Your Groq API key from https://console.groq.com/keys
13
+
14
+ ## How to Set Secrets in Hugging Face Spaces:
15
+
16
+ 1. Go to your Space page on Hugging Face
17
+ 2. Click "Settings" tab
18
+ 3. Scroll down to "Variables and secrets"
19
+ 4. Click "New secret"
20
+ 5. Enter the secret name and value
21
+ 6. Click "Save"
22
+ 7. Your app will automatically restart with the new secret
23
+
24
+ ## Getting a Groq API Key:
25
+
26
+ 1. Visit https://console.groq.com/keys
27
+ 2. Create a free account
28
+ 3. Generate a new API key
29
+ 4. Copy the key and add it to your Hugging Face Space secrets
30
+
31
+ ## Note:
32
+ Without the GROQ_API_KEY, the app will show warnings but should still launch. However, the AI coaching functionality will not work.
config.py CHANGED
@@ -51,4 +51,9 @@ PIPER_VOICE_MODEL = './voice_model/en_US-lessac-medium.onnx'
51
 
52
  # -- Directories --
53
  UPLOAD_FOLDER = 'uploads'
54
- REPORT_FOLDER = 'reports'
 
 
 
 
 
 
51
 
52
  # -- Directories --
53
  UPLOAD_FOLDER = 'uploads'
54
+ REPORT_FOLDER = 'reports'
55
+
56
+ # Ensure directories exist
57
+ import os
58
+ os.makedirs(UPLOAD_FOLDER, exist_ok=True)
59
+ os.makedirs(REPORT_FOLDER, exist_ok=True)
modules/llm_handler.py CHANGED
@@ -1,7 +1,7 @@
1
  # modules/llm_handler.py
2
  import os
3
  import config
4
- import regex as re
5
  from groq import Groq
6
  from modules.web_search import search_for_example_answers
7
  from modules.pm_frameworks import get_framework_suggestion, get_relevant_metrics
 
1
  # modules/llm_handler.py
2
  import os
3
  import config
4
+ import re
5
  from groq import Groq
6
  from modules.web_search import search_for_example_answers
7
  from modules.pm_frameworks import get_framework_suggestion, get_relevant_metrics
modules/tts_handler.py CHANGED
@@ -28,6 +28,26 @@ def text_to_speech_file(text_to_speak):
28
  else:
29
  print("❌ macOS 'say' command failed, falling back to silent audio")
30
  return create_silent_audio()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  else:
32
  print("❌ TTS not available on this system, using silent audio")
33
  return create_silent_audio()
 
28
  else:
29
  print("❌ macOS 'say' command failed, falling back to silent audio")
30
  return create_silent_audio()
31
+
32
+ # Try Linux TTS options
33
+ elif platform.system() == "Linux":
34
+ # Check if espeak is available (common on Linux systems)
35
+ if subprocess.run(['which', 'espeak'], capture_output=True).returncode == 0:
36
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as wav_file:
37
+ wav_filename = wav_file.name
38
+
39
+ command = ['espeak', '-w', wav_filename, text_to_speak]
40
+ process = subprocess.run(command, capture_output=True, text=True, timeout=30)
41
+
42
+ if process.returncode == 0 and os.path.exists(wav_filename):
43
+ print("βœ… TTS generated successfully with espeak")
44
+ return wav_filename
45
+ else:
46
+ print("❌ espeak command failed, falling back to silent audio")
47
+ return create_silent_audio()
48
+ else:
49
+ print("❌ No TTS engine available on Linux, using silent audio")
50
+ return create_silent_audio()
51
  else:
52
  print("❌ TTS not available on this system, using silent audio")
53
  return create_silent_audio()
packages.txt CHANGED
@@ -1,2 +1,6 @@
1
  ffmpeg
2
- portaudio19-dev
 
 
 
 
 
1
  ffmpeg
2
+ portaudio19-dev
3
+ espeak
4
+ espeak-data
5
+ libespeak1
6
+ alsa-utils