Spaces:
				
			
			
	
			
			
		Running
		
			on 
			
			Zero
	
	
	
			
			
	
	
	
	
		
		
		Running
		
			on 
			
			Zero
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -169,6 +169,107 @@ def load_sample_text(sample_index): | |
| 169 | 
             
                return ""
         | 
| 170 |  | 
| 171 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 172 | 
             
            # Create Gradio interfacegr
         | 
| 173 | 
             
            with gr.Blocks(
         | 
| 174 | 
             
                title="Vui",
         | 
|  | |
| 169 | 
             
                return ""
         | 
| 170 |  | 
| 171 |  | 
| 172 | 
            +
            # added by on1onmangoes at Tue Jan 10 to make into claude mcp server 
         | 
| 173 | 
            +
            # MCP Server Functions - Add these after your existing functions
         | 
| 174 | 
            +
            def generate_podcast_audio_mcp(text, temperature=0.5, top_k=100, max_duration=60):
         | 
| 175 | 
            +
                """
         | 
| 176 | 
            +
                Generate podcast-style audio from text using AI voice synthesis.
         | 
| 177 | 
            +
                
         | 
| 178 | 
            +
                Args:
         | 
| 179 | 
            +
                    text: The podcast script or text to convert to speech
         | 
| 180 | 
            +
                    temperature: Voice variation (0.1-1.0, higher = more varied) 
         | 
| 181 | 
            +
                    top_k: Top-k sampling parameter (1-200)
         | 
| 182 | 
            +
                    max_duration: Maximum audio duration in seconds
         | 
| 183 | 
            +
                    
         | 
| 184 | 
            +
                Returns:
         | 
| 185 | 
            +
                    String with audio generation status and metadata
         | 
| 186 | 
            +
                """
         | 
| 187 | 
            +
                if not text.strip():
         | 
| 188 | 
            +
                    return "Error: Please provide text to convert to speech"
         | 
| 189 | 
            +
                
         | 
| 190 | 
            +
                if current_model is None:
         | 
| 191 | 
            +
                    return "Error: No voice model loaded"
         | 
| 192 | 
            +
                
         | 
| 193 | 
            +
                try:
         | 
| 194 | 
            +
                    # Use your existing text_to_speech function
         | 
| 195 | 
            +
                    audio_result, info = text_to_speech(text, temperature, top_k, None, max_duration)
         | 
| 196 | 
            +
                    
         | 
| 197 | 
            +
                    if audio_result is None:
         | 
| 198 | 
            +
                        return f"Error: {info}"
         | 
| 199 | 
            +
                    
         | 
| 200 | 
            +
                    sample_rate, audio_array = audio_result
         | 
| 201 | 
            +
                    duration = len(audio_array) / sample_rate
         | 
| 202 | 
            +
                    
         | 
| 203 | 
            +
                    return f"✅ Generated {duration:.1f}s of podcast audio successfully. {info}"
         | 
| 204 | 
            +
                    
         | 
| 205 | 
            +
                except Exception as e:
         | 
| 206 | 
            +
                    return f"Error generating podcast audio: {str(e)}"
         | 
| 207 | 
            +
             | 
| 208 | 
            +
            def get_podcast_samples_mcp():
         | 
| 209 | 
            +
                """
         | 
| 210 | 
            +
                Get sample podcast texts that can be used for audio generation.
         | 
| 211 | 
            +
                
         | 
| 212 | 
            +
                Returns:
         | 
| 213 | 
            +
                    String with formatted sample podcast scripts
         | 
| 214 | 
            +
                """
         | 
| 215 | 
            +
                samples_info = []
         | 
| 216 | 
            +
                for i, sample in enumerate(SAMPLE_TEXTS):
         | 
| 217 | 
            +
                    samples_info.append(f"**Sample {i+1}:** {sample[:100]}...")
         | 
| 218 | 
            +
                
         | 
| 219 | 
            +
                return "Available podcast samples:\n\n" + "\n\n".join(samples_info)
         | 
| 220 | 
            +
             | 
| 221 | 
            +
            def get_full_podcast_sample_mcp(sample_number):
         | 
| 222 | 
            +
                """
         | 
| 223 | 
            +
                Get the full text of a specific podcast sample.
         | 
| 224 | 
            +
                
         | 
| 225 | 
            +
                Args:
         | 
| 226 | 
            +
                    sample_number: Sample number (1-4)
         | 
| 227 | 
            +
                    
         | 
| 228 | 
            +
                Returns:
         | 
| 229 | 
            +
                    Full text of the requested sample
         | 
| 230 | 
            +
                """
         | 
| 231 | 
            +
                try:
         | 
| 232 | 
            +
                    index = int(sample_number) - 1
         | 
| 233 | 
            +
                    if 0 <= index < len(SAMPLE_TEXTS):
         | 
| 234 | 
            +
                        return f"Sample {sample_number} full text:\n\n{SAMPLE_TEXTS[index]}"
         | 
| 235 | 
            +
                    else:
         | 
| 236 | 
            +
                        return f"Error: Sample {sample_number} not found. Available samples: 1-{len(SAMPLE_TEXTS)}"
         | 
| 237 | 
            +
                except ValueError:
         | 
| 238 | 
            +
                    return "Error: Please provide a valid sample number (1-4)"
         | 
| 239 | 
            +
             | 
| 240 | 
            +
            def change_voice_model_mcp(model_name):
         | 
| 241 | 
            +
                """
         | 
| 242 | 
            +
                Change the active voice model for podcast generation.
         | 
| 243 | 
            +
                
         | 
| 244 | 
            +
                Args:
         | 
| 245 | 
            +
                    model_name: Name of the voice model to load (currently only COHOST available)
         | 
| 246 | 
            +
                    
         | 
| 247 | 
            +
                Returns:
         | 
| 248 | 
            +
                    Status message indicating success or failure
         | 
| 249 | 
            +
                """
         | 
| 250 | 
            +
                try:
         | 
| 251 | 
            +
                    if model_name not in AVAILABLE_MODELS:
         | 
| 252 | 
            +
                        available = ", ".join(AVAILABLE_MODELS.keys())
         | 
| 253 | 
            +
                        return f"Error: Model '{model_name}' not available. Available models: {available}"
         | 
| 254 | 
            +
                    
         | 
| 255 | 
            +
                    status = change_model(model_name)
         | 
| 256 | 
            +
                    return status
         | 
| 257 | 
            +
                except Exception as e:
         | 
| 258 | 
            +
                    return f"Error changing model: {str(e)}"
         | 
| 259 | 
            +
             | 
| 260 | 
            +
            def get_voice_models_info_mcp():
         | 
| 261 | 
            +
                """
         | 
| 262 | 
            +
                Get information about available voice models.
         | 
| 263 | 
            +
                
         | 
| 264 | 
            +
                Returns:
         | 
| 265 | 
            +
                    String with available voice models and current model status
         | 
| 266 | 
            +
                """
         | 
| 267 | 
            +
                available = ", ".join(AVAILABLE_MODELS.keys())
         | 
| 268 | 
            +
                current = current_model_name if current_model_name else "Unknown"
         | 
| 269 | 
            +
                
         | 
| 270 | 
            +
                return f"Available voice models: {available}\nCurrently loaded: {current}"
         | 
| 271 | 
            +
             | 
| 272 | 
            +
             | 
| 273 | 
             
            # Create Gradio interfacegr
         | 
| 274 | 
             
            with gr.Blocks(
         | 
| 275 | 
             
                title="Vui",
         | 
