Spaces:
Sleeping
Sleeping
Update app.py
Browse files13 unmodified lines14151617181920171819232021222327282930313224252625 unmodified lines525354645556575831 unmodified lines909192102103939495969756 unmodified lines15415515616616715715815916016176 unmodified lines23823924025024124224324482 unmodified lines32732832933933033133233367 unmodified lines40140240341340440540613 unmodified lines
warnings.filterwarnings("ignore")
# Add this at the top of your app.py or equivalentimport nltk
# Download necessary NLTK data# Download required NLTK data including punkt_tabtry: nltk.data.find('tokenizers/punkt') nltk.data.find('tokenizers/punkt_tab') # This is the missing one! nltk.data.find('tokenizers/punkt_tab')except LookupError: nltk.download(['punkt', 'punkt_tab'], quiet=True)
# Download required NLTK datatry: nltk.data.find('tokenizers/punkt')except LookupError: nltk.download('punkt')
class LongFormTTS: def __init__(self):25 unmodified lines # Handle common abbreviations abbreviations = { 'Dr.': 'Doctor', 'Mr.': 'Mister', 'Mr.': 'Mister', 'Mrs.': 'Missus', 'Ms.': 'Miss', 'Prof.': 'Professor',31 unmodified lines if num > 9999: return str(num) ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"] if num < 10: return ones[num]56 unmodified lines inputs = self.processor(text=text_chunk, return_tensors="pt").to(self.device) with torch.no_grad(): speech = self.model.generate_speech( inputs["input_ids"], self.speaker_embeddings, inputs["input_ids"], self.speaker_embeddings, vocoder=self.vocoder ) # Convert to numpy and move to CPU76 unmodified lines return None, "β Failed to generate audio. Please try with different text." progress(0.9, desc="πΎ Saving audio file...") # Save to temporary file with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file: with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file: sf.write(tmp_file.name, audio, sample_rate) audio_path = tmp_file.name progress(1.0, desc="β
Complete!")82 unmodified lines <li>π Natural human voice</li> <li>β‘ Smart text processing</li> <li>π§ Auto chunking</li> <li>_FREE_ Completely free</li> <li>π Completely free</li> <li>π± Mobile friendly</li> <li>π΅ High quality audio</li> </ul>67 unmodified lines demo.launch( server_name="0.0.0.0", server_port=7860, share=True share=True, ssr_mode=False )app.py+11-19