Spaces:
Sleeping
Sleeping
File size: 1,176 Bytes
ffd4428 335f18b ffd4428 335f18b a5643e3 03272c6 fa0b08d 35f5bf3 ebd8530 03272c6 35f5bf3 4673afc e72a96e a716b14 e72a96e 787f0bf e72a96e 2024f9a dbb5e58 2024f9a e72a96e 2024f9a dbb5e58 2024f9a 0e7be6c fa0b08d |
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 36 37 38 39 40 41 |
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")
def text2audio(text):
pipe = pipeline("text-to-audio", model="Matthijs/mms-tts-eng")
audio_data = pipe(text)
return audio_data
st.set_page_config(page_title="Tweet Toxicity Analysis")
st.header("Please input a Tweet for Toxicity Analysis :performing_arts:")
input = st.text_area("Enter a Tweer for analysis")
if st.button("Toxic Analysis"):
result = toxic_model(input)
# Display the result
st.write("Tweet:", input)
st.write("label:", result[0]['label'])
st.write("score:", result[0]['score'])
# Read the result
audio_data1 = text2audio(input)
st.audio(audio_data1['audio'],
format="audio/wav",
start_time=0,
sample_rate = audio_data1['sampling_rate'])
audio_data2 = text2audio(result[0]['label'])
st.audio(audio_data2['audio'],
format="audio/wav",
start_time=0,
sample_rate = audio_data2['sampling_rate'])
|