#!/usr/bin/env python3 from huggingface_hub import HfApi import os # Create the final, cleanest possible HuggingFace Space api = HfApi() try: # Create ultra-simple Gradio app simple_app = '''import gradio as gr import time def health_check(): return { "status": "healthy", "timestamp": time.time(), "message": "STT Service Test - Ready for model integration" } def placeholder_transcribe(audio): if audio is None: return "No audio provided" return f"Placeholder: Audio received (type: {type(audio)}) - STT model integration pending" # Create interface with gr.Blocks(title="STT GPU Service Working Test") as demo: gr.Markdown("# šŸŽ™ļø STT GPU Service - Working Test") gr.Markdown("Successfully deployed! Ready for STT model integration.") with gr.Tab("Health Check"): health_btn = gr.Button("Check Health") health_output = gr.JSON() health_btn.click(health_check, outputs=health_output) with gr.Tab("Audio Test"): audio_input = gr.Audio(type="numpy") transcribe_btn = gr.Button("Test Transcribe") output_text = gr.Textbox() transcribe_btn.click(placeholder_transcribe, inputs=audio_input, outputs=output_text) if __name__ == "__main__": demo.launch() ''' # Simple requirements simple_requirements = '''gradio''' # Clean README clean_readme = '''--- title: STT GPU Service Working Test emoji: šŸŽ™ļø colorFrom: blue colorTo: green sdk: gradio app_file: app.py pinned: false --- # STT GPU Service - Working Test Basic deployment test - ready for STT model integration once verified working. ''' # Write files locally first with open('app_final.py', 'w') as f: f.write(simple_app) with open('requirements_final.txt', 'w') as f: f.write(simple_requirements) with open('README_final.md', 'w') as f: f.write(clean_readme) print("Created clean deployment files locally") # Create completely fresh space space_url = api.create_repo( repo_id="pgits/stt-working-test", repo_type="space", exist_ok=True, space_sdk="gradio" ) print(f"Clean Space created: {space_url}") # Upload with explicit main branch targeting files = [ ("app_final.py", "app.py"), ("requirements_final.txt", "requirements.txt"), ("README_final.md", "README.md") ] for local_file, repo_file in files: print(f"Uploading {local_file} as {repo_file} to main branch...") api.upload_file( path_or_fileobj=local_file, path_in_repo=repo_file, repo_id="pgits/stt-working-test", repo_type="space", revision="main", commit_message=f"Deploy {repo_file} for working STT service test" ) print(f"āœ… {repo_file} deployed") print("\nšŸš€ FINAL CLEAN DEPLOYMENT COMPLETED!") print(f"šŸ”— URL: https://huggingface.co/spaces/pgits/stt-working-test") print("šŸ“‹ This should work - cleanest possible Gradio deployment") except Exception as e: print(f"āŒ Error: {e}")