sukanya15 commited on
Commit
272f2fd
Β·
verified Β·
1 Parent(s): 849abbc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +612 -0
app.py ADDED
@@ -0,0 +1,612 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import speech_recognition as sr
3
+ from gtts import gTTS
4
+ import io
5
+ import base64
6
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
7
+ import torch
8
+ import tempfile
9
+ import os
10
+ import time
11
+ import warnings
12
+ warnings.filterwarnings("ignore")
13
+ st.set_page_config(
14
+ page_title="GenBridge - Voice AI Document Generator",
15
+ page_icon="🧠",
16
+ layout="wide"
17
+ )
18
+
19
+ # Initialize session state
20
+ if 'generated_content' not in st.session_state:
21
+ st.session_state.generated_content = ""
22
+ if 'audio_file' not in st.session_state:
23
+ st.session_state.audio_file = None
24
+ if 'user_input' not in st.session_state:
25
+ st.session_state.user_input = ""
26
+
27
+ @st.cache_resource
28
+ def load_granite_model():
29
+ """Load IBM Granite model optimized for Hugging Face Spaces"""
30
+ try:
31
+ st.info("πŸ”„ Loading IBM Granite AI model...")
32
+
33
+ # Using IBM Granite 3B - optimized for Hugging Face Spaces
34
+ model_name = "ibm-granite/granite-3b-code-instruct"
35
+
36
+ # Use pipeline for easier handling in HF Spaces
37
+ generator = pipeline(
38
+ "text-generation",
39
+ model=model_name,
40
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
41
+ device_map="auto" if torch.cuda.is_available() else None,
42
+ trust_remote_code=True,
43
+ max_new_tokens=512,
44
+ temperature=0.7,
45
+ do_sample=True,
46
+ repetition_penalty=1.1
47
+ )
48
+
49
+ st.success("βœ… IBM Granite model loaded successfully!")
50
+ return generator
51
+
52
+ except Exception as e:
53
+ st.warning(f"Granite model loading issue: {e}")
54
+ st.info("πŸ”„ Loading alternative model for demo...")
55
+
56
+ try:
57
+ # Fallback to a reliable model available on HF
58
+ generator = pipeline(
59
+ "text-generation",
60
+ model="microsoft/DialoGPT-medium",
61
+ max_new_tokens=300,
62
+ temperature=0.7,
63
+ do_sample=True
64
+ )
65
+ st.warning("⚠ Using demo model. Upgrade to Granite for production.")
66
+ return generator
67
+ except Exception as e2:
68
+ st.error(f"Model loading failed: {e2}")
69
+ return None
70
+
71
+ def speech_to_text_demo():
72
+ """Demo speech-to-text (simulated for HF Spaces)"""
73
+ # Note: Microphone access is limited in HF Spaces
74
+ st.info("🎀 In a full deployment, this would capture your voice input!")
75
+
76
+ # For demo purposes, provide sample inputs
77
+ sample_inputs = {
78
+ "Resume": "I am a software engineer with 5 years experience in Python, web development, and machine learning. I have worked at tech startups and have skills in React, Django, and cloud platforms.",
79
+ "Cover Letter": "I am applying for a senior software developer position at your company. I have expertise in full-stack development and have led multiple successful projects.",
80
+ "Email": "I want to write a professional email to my manager requesting a meeting to discuss my career development and potential promotion opportunities.",
81
+ "Job Application": "I am interested in applying for the data scientist position. I have a Masters in Computer Science and 3 years experience in machine learning and data analysis."
82
+ }
83
+
84
+ return sample_inputs
85
+
86
+ def create_granite_prompt(user_input, document_type, tone):
87
+ """Create optimized prompt for IBM Granite model"""
88
+
89
+ base_instruction = "You are a professional document writer. Create a complete, well-structured, and professional document."
90
+
91
+ prompts = {
92
+ "Resume": f"""{base_instruction}
93
+
94
+ Create a professional resume with {tone.lower()} tone based on this information:
95
+ {user_input}
96
+
97
+ Include these sections:
98
+ - Professional Summary
99
+ - Core Skills
100
+ - Professional Experience
101
+ - Education
102
+ - Additional Qualifications
103
+
104
+ Make it comprehensive and {tone.lower()}:
105
+
106
+ """,
107
+
108
+ "Cover Letter": f"""{base_instruction}
109
+
110
+ Write a {tone.lower()} cover letter based on:
111
+ {user_input}
112
+
113
+ Include:
114
+ - Professional greeting
115
+ - Strong opening paragraph
116
+ - Body highlighting qualifications
117
+ - Professional closing
118
+ - {tone.lower()} tone throughout
119
+
120
+ Cover Letter:
121
+
122
+ """,
123
+
124
+ "Email": f"""{base_instruction}
125
+
126
+ Compose a {tone.lower()} professional email based on:
127
+ {user_input}
128
+
129
+ Include:
130
+ - Clear subject line
131
+ - Professional greeting
132
+ - Well-structured body
133
+ - Appropriate closing
134
+ - {tone.lower()} tone
135
+
136
+ Email:
137
+
138
+ """,
139
+
140
+ "Job Application": f"""{base_instruction}
141
+
142
+ Create a {tone.lower()} job application letter based on:
143
+ {user_input}
144
+
145
+ Include:
146
+ - Formal business format
147
+ - Statement of interest
148
+ - Relevant qualifications
149
+ - Request for interview
150
+ - Professional closing
151
+ - {tone.lower()} tone
152
+
153
+ Job Application:
154
+
155
+ """
156
+ }
157
+
158
+ return prompts.get(document_type, f"Create a {tone.lower()} {document_type} based on: {user_input}")
159
+
160
+ def generate_document_with_granite(user_input, document_type, tone):
161
+ """Generate document using IBM Granite model"""
162
+ generator = load_granite_model()
163
+
164
+ if generator is None:
165
+ return create_professional_template(document_type, user_input, tone)
166
+
167
+ prompt = create_granite_prompt(user_input, document_type, tone)
168
+
169
+ try:
170
+ # Generate with the model
171
+ results = generator(prompt, max_new_tokens=400, num_return_sequences=1)
172
+ generated_text = results[0]['generated_text']
173
+
174
+ # Extract the generated content (remove the prompt)
175
+ if len(generated_text) > len(prompt):
176
+ generated_content = generated_text[len(prompt):].strip()
177
+
178
+ # Clean up and validate content
179
+ if generated_content and len(generated_content) > 100:
180
+ return generated_content
181
+
182
+ # Fallback to template if generation is insufficient
183
+ return create_professional_template(document_type, user_input, tone)
184
+
185
+ except Exception as e:
186
+ st.error(f"Generation error: {e}")
187
+ return create_professional_template(document_type, user_input, tone)
188
+
189
+ def create_professional_template(document_type, user_input, tone):
190
+ """Create high-quality professional templates"""
191
+
192
+ templates = {
193
+ "Resume": f"""PROFESSIONAL RESUME
194
+
195
+ ═══════════════════════════════════════════════════
196
+
197
+ CONTACT INFORMATION
198
+ [Your Full Name]
199
+ Email: [[email protected]] | Phone: [Your Number]
200
+ LinkedIn: [LinkedIn Profile] | Location: [Your City, State]
201
+
202
+ PROFESSIONAL SUMMARY
203
+ {tone} and results-driven professional with proven expertise in the field. {user_input[:100]}... Demonstrated ability to deliver high-quality results while maintaining excellent professional standards.
204
+
205
+ CORE COMPETENCIES
206
+ β€’ Technical Skills & Expertise β€’ Leadership & Team Management
207
+ β€’ Strategic Planning & Execution β€’ Communication & Collaboration
208
+ β€’ Problem-Solving & Innovation β€’ Project Management
209
+ β€’ Quality Assurance & Best Practices β€’ Continuous Learning & Development
210
+
211
+ PROFESSIONAL EXPERIENCE
212
+
213
+ Senior Professional | [Company Name] | [Years]
214
+ β€’ Led cross-functional teams to achieve strategic objectives and deliver exceptional results
215
+ β€’ Developed and implemented innovative solutions that improved efficiency by 25%
216
+ β€’ Collaborated with stakeholders to identify requirements and exceed expectations
217
+ β€’ Mentored junior team members and contributed to professional development initiatives
218
+
219
+ Professional Specialist | [Previous Company] | [Years]
220
+ β€’ Executed complex projects while maintaining high standards of quality and accuracy
221
+ β€’ Analyzed requirements and delivered solutions that aligned with business objectives
222
+ β€’ Built strong professional relationships with clients and internal teams
223
+ β€’ Contributed to process improvements that enhanced overall productivity
224
+
225
+ EDUCATION & CERTIFICATIONS
226
+ [Degree] in [Field of Study] | [University Name] | [Year]
227
+ β€’ Relevant coursework: [Key subjects related to your field]
228
+ β€’ Professional certifications and continuing education
229
+
230
+ ADDITIONAL QUALIFICATIONS
231
+ β€’ Industry-specific knowledge and best practices
232
+ β€’ Strong analytical and technical capabilities
233
+ β€’ Excellent written and verbal communication skills
234
+ β€’ Proven track record of professional excellence
235
+
236
+ References available upon request
237
+
238
+ ---
239
+ Generated based on: "{user_input}" """,
240
+
241
+ "Cover Letter": f"""[Your Name]
242
+ [Your Address]
243
+ [City, State ZIP Code]
244
+ [Your Email]
245
+ [Your Phone Number]
246
+
247
+ [Date]
248
+
249
+ [Hiring Manager's Name]
250
+ [Company Name]
251
+ [Company Address]
252
+ [City, State ZIP Code]
253
+
254
+ Dear Hiring Manager,
255
+
256
+ I am writing to express my strong interest in joining your organization. Your company's reputation for excellence and innovation aligns perfectly with my professional values and career aspirations.
257
+
258
+ Based on your requirements and my background: {user_input}
259
+
260
+ I am confident that my qualifications and {tone.lower()} approach to professional challenges make me an ideal candidate for this opportunity. Throughout my career, I have consistently demonstrated:
261
+
262
+ β€’ Strong technical and analytical capabilities
263
+ β€’ Excellent communication and interpersonal skills
264
+ β€’ Proven ability to work effectively in team environments
265
+ β€’ Commitment to delivering high-quality results
266
+ β€’ Adaptability and eagerness to embrace new challenges
267
+
268
+ I am particularly drawn to this opportunity because it would allow me to contribute meaningfully to your organization's continued success while further developing my professional expertise. My background has prepared me well for the responsibilities outlined in your position description.
269
+
270
+ I would welcome the opportunity to discuss how my experience and enthusiasm can benefit your team. Thank you for your time and consideration. I look forward to hearing from you soon.
271
+
272
+ {tone}ly yours,
273
+
274
+ [Your Signature]
275
+ [Your Printed Name]
276
+
277
+ ---
278
+ Tailored based on: "{user_input}" """,
279
+
280
+ "Email": f"""Subject: Professional Inquiry - {user_input[:30]}...
281
+
282
+ Dear [Recipient Name],
283
+
284
+ I hope this message finds you well.
285
+
286
+ I am reaching out regarding: {user_input}
287
+
288
+ [MAIN MESSAGE CONTENT]
289
+ Thank you for taking the time to consider this matter. I have structured this communication to provide you with all relevant information while respecting your time.
290
+
291
+ Key points for your consideration:
292
+ β€’ Clear objective and professional context
293
+ β€’ Relevant background information and details
294
+ β€’ Specific next steps or requested actions
295
+ β€’ Timeline considerations if applicable
296
+
297
+ I am committed to maintaining the highest standards of professionalism in all communications and interactions. Please let me know if you require any additional information or clarification.
298
+
299
+ I appreciate your attention to this matter and look forward to your response at your earliest convenience.
300
+
301
+ Best professional regards,
302
+
303
+ [Your Name]
304
+ [Your Title/Position]
305
+ [Your Contact Information]
306
+ [Your Organization]
307
+
308
+ ---
309
+ Email generated based on: "{user_input}" """,
310
+
311
+ "Job Application": f"""[Your Name]
312
+ [Your Address]
313
+ [City, State ZIP Code]
314
+ [Your Email] | [Your Phone]
315
+
316
+ [Date]
317
+
318
+ [Hiring Manager Name]
319
+ [Company Name]
320
+ [Company Address]
321
+ [City, State ZIP Code]
322
+
323
+ Dear Hiring Manager,
324
+
325
+ I am writing to submit my formal application for the position advertised by your esteemed organization. After careful review of your requirements, I am excited about the opportunity to contribute to your team's continued success.
326
+
327
+ Your position requirements align excellently with my background: {user_input}
328
+
329
+ I am confident that my qualifications, combined with my {tone.lower()} approach to professional responsibilities, position me as a strong candidate for this role. My career has been built on a foundation of:
330
+
331
+ CORE QUALIFICATIONS:
332
+ β€’ Comprehensive educational background and relevant training
333
+ β€’ Proven professional experience in related fields
334
+ β€’ Strong analytical and problem-solving capabilities
335
+ β€’ Excellent communication and collaboration skills
336
+ β€’ Demonstrated commitment to professional excellence
337
+ β€’ Track record of contributing to organizational success
338
+
339
+ PROFESSIONAL ATTRIBUTES:
340
+ β€’ Results-oriented mindset with attention to detail
341
+ β€’ Ability to work effectively both independently and in teams
342
+ β€’ Strong work ethic and reliability
343
+ β€’ Adaptability and eagerness to learn new skills
344
+ β€’ Commitment to maintaining high professional standards
345
+
346
+ I am particularly interested in this opportunity because it represents the perfect intersection of my professional expertise and career objectives. I am confident that I can make immediate and lasting contributions to your organization.
347
+
348
+ I would be honored to discuss my qualifications in greater detail during an interview. Thank you for your time and consideration of my application. I look forward to the opportunity to speak with you soon.
349
+
350
+ Respectfully submitted,
351
+
352
+ [Your Signature]
353
+ [Your Printed Name]
354
+
355
+ Enclosures: Resume, References
356
+
357
+ ---
358
+ Application created based on: "{user_input}" """
359
+ }
360
+
361
+ return templates.get(document_type, f"Professional {document_type} created based on your requirements: {user_input}")
362
+
363
+ def text_to_speech(text):
364
+ """Convert text to speech - optimized for HF Spaces"""
365
+ try:
366
+ # Limit text length for better performance in HF Spaces
367
+ if len(text) > 2000:
368
+ text = text[:2000] + "..."
369
+
370
+ tts = gTTS(text=text, lang='en', slow=False)
371
+
372
+ # Create temporary file
373
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.mp3') as tmp_file:
374
+ tts.save(tmp_file.name)
375
+ return tmp_file.name
376
+
377
+ except Exception as e:
378
+ st.error(f"Audio generation error: {e}")
379
+ return None
380
+
381
+ def main():
382
+ # Custom CSS for better styling
383
+ st.markdown("""
384
+ <style>
385
+ .main-header {
386
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
387
+ padding: 2rem;
388
+ border-radius: 10px;
389
+ text-align: center;
390
+ color: white;
391
+ margin-bottom: 2rem;
392
+ }
393
+ .feature-box {
394
+ background: #f8f9fa;
395
+ padding: 1rem;
396
+ border-radius: 8px;
397
+ border-left: 4px solid #667eea;
398
+ margin: 1rem 0;
399
+ }
400
+ </style>
401
+ """, unsafe_allow_html=True)
402
+
403
+ # Header
404
+ st.markdown("""
405
+ <div class="main-header">
406
+ <h1>🧠 GenBridge</h1>
407
+ <h3>Voice-Powered AI Document Generator</h3>
408
+ <p>Powered by IBM Granite AI | Built for Accessibility</p>
409
+ </div>
410
+ """, unsafe_allow_html=True)
411
+
412
+ # Sidebar
413
+ with st.sidebar:
414
+ st.header("βš™ Configuration")
415
+
416
+ document_type = st.selectbox(
417
+ "πŸ“‹ Document Type:",
418
+ ["Resume", "Cover Letter", "Email", "Job Application"],
419
+ help="Choose the type of document to generate"
420
+ )
421
+
422
+ tone = st.selectbox(
423
+ "🎨 Writing Tone:",
424
+ ["Professional", "Friendly", "Formal", "Assertive"],
425
+ help="Select the tone for your document"
426
+ )
427
+
428
+ st.markdown("---")
429
+
430
+ st.markdown("### 🎯 Key Features")
431
+ st.markdown("""
432
+ - 🎀 *Voice Input*: Natural speech interface
433
+ - 🧠 *IBM Granite AI*: Advanced text generation
434
+ - πŸ”Š *Audio Output*: Text-to-speech playback
435
+ - πŸ’Ύ *Downloads*: Text & audio files
436
+ - β™Ώ *Accessible*: Built for everyone
437
+ """)
438
+
439
+ st.markdown("---")
440
+ st.markdown("### πŸ‘₯ Target Users")
441
+ st.markdown("""
442
+ - Visually impaired individuals
443
+ - Elderly users
444
+ - Job seekers
445
+ - Non-native speakers
446
+ - Anyone preferring voice interaction
447
+ """)
448
+
449
+ st.markdown("---")
450
+ st.info("πŸ’‘ *Demo Note*: This is running on Hugging Face Spaces. Voice input is simulated with sample data.")
451
+
452
+ # Main content
453
+ col1, col2 = st.columns([1, 1])
454
+
455
+ with col1:
456
+ st.header("🎀 Input Method")
457
+
458
+ input_choice = st.radio(
459
+ "Choose input method:",
460
+ ["🎀 Voice Input (Demo)", "⌨ Custom Text Input"]
461
+ )
462
+
463
+ if input_choice == "🎀 Voice Input (Demo)":
464
+ st.markdown("### πŸŽ™ Voice Input Simulation")
465
+ st.info("In production, this would capture live voice input!")
466
+
467
+ samples = speech_to_text_demo()
468
+ selected_sample = st.selectbox(
469
+ "Choose a sample voice input:",
470
+ list(samples.keys()),
471
+ help="These represent typical voice inputs"
472
+ )
473
+
474
+ if st.button("🎀 Simulate Voice Input", type="primary"):
475
+ st.session_state.user_input = samples[selected_sample]
476
+ st.success(f"βœ… Voice input captured!")
477
+
478
+ else:
479
+ custom_input = st.text_area(
480
+ "Enter your requirements:",
481
+ height=120,
482
+ placeholder="Describe your background, skills, experience, or what you want to include in your document...",
483
+ help="Provide detailed information for better document generation"
484
+ )
485
+
486
+ if custom_input:
487
+ st.session_state.user_input = custom_input
488
+
489
+ # Show current input
490
+ if st.session_state.user_input:
491
+ st.markdown("### πŸ“ Current Input:")
492
+ st.success(st.session_state.user_input)
493
+
494
+ with col2:
495
+ st.header("🧠 AI Generation")
496
+
497
+ if st.session_state.user_input:
498
+ if st.button("✨ Generate with IBM Granite AI", type="primary", use_container_width=True):
499
+ with st.spinner(f"πŸ€– Creating your {document_type.lower()} using IBM Granite..."):
500
+ # Add progress bar for better UX
501
+ progress_bar = st.progress(0)
502
+ progress_bar.progress(25)
503
+
504
+ generated_content = generate_document_with_granite(
505
+ st.session_state.user_input,
506
+ document_type,
507
+ tone
508
+ )
509
+ progress_bar.progress(75)
510
+
511
+ st.session_state.generated_content = generated_content
512
+
513
+ # Generate audio
514
+ audio_file = text_to_speech(generated_content)
515
+ st.session_state.audio_file = audio_file
516
+ progress_bar.progress(100)
517
+
518
+ st.success("βœ… Document generated successfully!")
519
+ else:
520
+ st.info("πŸ‘† Please provide input to generate your document")
521
+
522
+ # Results section
523
+ if st.session_state.generated_content:
524
+ st.markdown("---")
525
+ st.header("πŸ“„ Generated Document")
526
+
527
+ # Display tabs for better organization
528
+ tab1, tab2, tab3 = st.tabs(["πŸ“„ Document", "πŸ”Š Audio", "πŸ’Ύ Downloads"])
529
+
530
+ with tab1:
531
+ st.markdown("### Your Generated Document:")
532
+ st.text_area(
533
+ "Generated Content:",
534
+ value=st.session_state.generated_content,
535
+ height=400,
536
+ disabled=True
537
+ )
538
+
539
+ # Word and character count
540
+ word_count = len(st.session_state.generated_content.split())
541
+ char_count = len(st.session_state.generated_content)
542
+ st.caption(f"πŸ“Š Statistics: {word_count} words | {char_count} characters")
543
+
544
+ with tab2:
545
+ st.markdown("### πŸ”Š Audio Playback:")
546
+ if st.session_state.audio_file and os.path.exists(st.session_state.audio_file):
547
+ with open(st.session_state.audio_file, 'rb') as audio_file:
548
+ audio_bytes = audio_file.read()
549
+ st.audio(audio_bytes, format='audio/mp3')
550
+ st.success("🎡 Audio generated successfully!")
551
+ else:
552
+ st.warning("Audio generation in progress...")
553
+
554
+ with tab3:
555
+ st.markdown("### πŸ’Ύ Download Your Files:")
556
+
557
+ col1, col2 = st.columns(2)
558
+
559
+ with col1:
560
+ # Text download
561
+ filename_text = f"{document_type.lower().replace(' ', '')}{int(time.time())}.txt"
562
+ st.download_button(
563
+ label="πŸ“„ Download Text Document",
564
+ data=st.session_state.generated_content,
565
+ file_name=filename_text,
566
+ mime="text/plain",
567
+ use_container_width=True
568
+ )
569
+
570
+ with col2:
571
+ # Audio download
572
+ if st.session_state.audio_file and os.path.exists(st.session_state.audio_file):
573
+ with open(st.session_state.audio_file, 'rb') as audio_file:
574
+ audio_bytes = audio_file.read()
575
+
576
+ filename_audio = f"{document_type.lower().replace(' ', '')}{int(time.time())}.mp3"
577
+ st.download_button(
578
+ label="πŸ”Š Download Audio Version",
579
+ data=audio_bytes,
580
+ file_name=filename_audio,
581
+ mime="audio/mp3",
582
+ use_container_width=True
583
+ )
584
+
585
+ # Action buttons
586
+ col1, col2 = st.columns(2)
587
+ with col1:
588
+ if st.button("πŸ”„ Generate New Version", use_container_width=True):
589
+ st.session_state.generated_content = ""
590
+ st.session_state.audio_file = None
591
+ st.rerun()
592
+
593
+ with col2:
594
+ if st.button("🎀 New Input", use_container_width=True):
595
+ st.session_state.user_input = ""
596
+ st.session_state.generated_content = ""
597
+ st.session_state.audio_file = None
598
+ st.rerun()
599
+
600
+ # Footer
601
+ st.markdown("---")
602
+ st.markdown("""
603
+ <div style='text-align: center; background: #f8f9fa; padding: 1rem; border-radius: 8px;'>
604
+ <h4>🧠 GenBridge - Democratizing Document Creation</h4>
605
+ <p><strong>Powered by:</strong> IBM Granite AI β€’ Hugging Face β€’ Streamlit</p>
606
+ <p><strong>Built for:</strong> Accessibility β€’ Inclusion β€’ Professional Excellence</p>
607
+ <p style='color: #666; font-size: 0.9em;'>Empowering visually impaired, elderly, and all users to create professional documents through voice</p>
608
+ </div>
609
+ """, unsafe_allow_html=True)
610
+
611
+ if _name_ == "_main_":
612
+ Β Β Β Β main()