Spaces:
Sleeping
Sleeping
File size: 1,294 Bytes
ffd4428 335f18b ffd4428 335f18b a5643e3 03272c6 fa0b08d 35f5bf3 ebd8530 03272c6 35f5bf3 a716b14 6fa920b ffe91fc 787f0bf 03272c6 2024f9a 03272c6 2024f9a 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")
result = toxic_model(input)
# Display the result
st.write("Tweet:", input)
st.write("label:", result[0]['label'])
st.write("score:", result[0]['score'])
text2audio("Tweet:", input)
st.audio(audio_data['audio'],
format="audio/wav",
start_time=0,
sample_rate = audio_data['sampling_rate'])
text2audio("label:", result[0]['label'])
st.audio(audio_data['audio'],
format="audio/wav",
start_time=0,
sample_rate = audio_data['sampling_rate'])
text2audio("score:", result[0]['score'])
st.audio(audio_data['audio'],
format="audio/wav",
start_time=0,
sample_rate = audio_data['sampling_rate'])
|