Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,11 @@ def analyze_sentiment(text):
|
|
19 |
def format_sentiment_text(sentiment, probability):
|
20 |
return f"The sentiment of the text is {sentiment} with a probability of {probability:.2f}."
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
def text_to_audio(text):
|
23 |
audio = text_audio_pipeline(text)
|
24 |
return audio
|
@@ -35,6 +40,7 @@ if input_text:
|
|
35 |
# Stage 2: Convert text to audio
|
36 |
st.text('Generating audio...')
|
37 |
sentiment_text_for_audio = f"The sentiment of the input text is {sentiment}, and the probability is {probability:.2f}."
|
|
|
38 |
audio_data = text_to_audio(sentiment_text_for_audio)
|
39 |
|
40 |
# Play button
|
|
|
19 |
def format_sentiment_text(sentiment, probability):
|
20 |
return f"The sentiment of the text is {sentiment} with a probability of {probability:.2f}."
|
21 |
|
22 |
+
def preprocess_text(text):
|
23 |
+
words = text.split()
|
24 |
+
processed_words = [p.number_to_words(word) if word.isdigit() else word for word in words]
|
25 |
+
return ' '.join(processed_words)
|
26 |
+
|
27 |
def text_to_audio(text):
|
28 |
audio = text_audio_pipeline(text)
|
29 |
return audio
|
|
|
40 |
# Stage 2: Convert text to audio
|
41 |
st.text('Generating audio...')
|
42 |
sentiment_text_for_audio = f"The sentiment of the input text is {sentiment}, and the probability is {probability:.2f}."
|
43 |
+
sentiment_text_for_audio = preprocess_text(sentiment_text_for_audio)
|
44 |
audio_data = text_to_audio(sentiment_text_for_audio)
|
45 |
|
46 |
# Play button
|