Spaces:
Configuration error
Configuration error
File size: 1,097 Bytes
192f98f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from transformers import pipeline
from gtts import gTTS
# Loading models
summarizer = pipeline("summarization", model="facebook/bart-large-cnn") # Load summarizer
sentiment_analyzer = pipeline("sentiment-analysis") # Load sentiment analyzer
# classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") # Load classifier
def analyze_sentiment(text):
result = sentiment_analyzer(text[:500])[0]
return result['label']
def summarize_text(text):
cleaned_text = text.strip().replace("\n", " ")
cleaned_text = cleaned_text[:3000] # Limit to avoid token overflow
result = summarizer(
cleaned_text,
max_length=130,
min_length=30,
do_sample=False
)
summary_text = result[0]['summary_text']
return summary_text
def generate_hindi_tts(text, filename="output.mp3"):
try:
tts = gTTS(text=text, lang='hi')
tts.save(filename)
print(f"Hindi audio saved to {filename}")
return filename
except Exception as e:
print(f"Error in generating the TTS: {e}")
return None |