Spaces:
Sleeping
Sleeping
import streamlit as st | |
# Use a pipeline as a high-level helper | |
from transformers import pipeline | |
toxic_model = pipeline("text-classification", model="Matt09Miao/GP5_tweet_toxic") | |
text2tweet = pipeline("text2text-generation", model="google/t5-v1_1-base") | |
# text2audio | |
def text2audio(toxic_result): | |
pipe = pipeline("text-to-audio", model="Matthijs/mms-tts-eng") | |
audio_data = pipe(toxic_result) | |
return audio_data | |
st.set_page_config(page_title="Generate Your Tweet and Toxicity Analysis") | |
st.header("Please input your first word of a Tweet :performing_arts:") | |
input = st.text_input("Please input your first word...") | |
if input is not None: | |
#Stage 1: Input to Tweet | |
st.text('Generating a Tweet...') | |
tweet = text2tweet(input) | |
st.write(tweet) | |
#Stage 2: Tweet Toxicity Analysis | |
#Stage 3: Story to Audio data | |
st.text('Generating audio data...') | |
audio_data =text2audio(tweet) | |
# Play button | |
if st.button("Play Audio"): | |
st.audio(audio_data['audio'], | |
format="audio/wav", | |
start_time=0, | |
sample_rate = audio_data['sampling_rate']) |