ysharma HF staff commited on
Commit
3ea2f71
1 Parent(s): 2f2dcab
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -10,6 +10,10 @@ from datasets import load_dataset
10
  import random
11
 
12
  dataset = load_dataset("ysharma/short_jokes", split="train")
 
 
 
 
13
 
14
  # Model 2: Sentence Transformer
15
  API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/msmarco-distilbert-base-tas-b"
@@ -47,7 +51,7 @@ def driver_fun(audio) :
47
  lower_limit = random_val - 5000
48
  upper_limit = random_val
49
  print(f"lower_limit : upper_limit = {lower_limit} : {upper_limit}")
50
- dataset_subset = dataset['Joke'][lower_limit : upper_limit]
51
  data = query({"inputs": {"source_sentence": "That is a happy person","sentences": dataset_subset} } )
52
  if 'error' in data:
53
  print(f"Error is : {data}")
@@ -106,7 +110,7 @@ demo = gr.Blocks()
106
  with demo:
107
  gr.Markdown("<h1><center>AI Assistant - Voice to Joke</center></h1>")
108
  gr.Markdown(
109
- """<center>This is still a work in porgress</center><br><br><br>Model pipeline consisting of - <br>- [**Whisper**](https://github.com/openai/whisper) for Speech-to-text, <br>- [**CoquiTTS**](https://huggingface.co/coqui) for Text-To-Speech. <br>- Front end is built using [**Gradio Block API**](https://gradio.app/docs/#blocks).<br><be><u>Ask Whisper for a joke about anything you would wish</u>.<br>If you want to reuse the App, simply click on the small cross button in the top right corner of your voice record panel, and then press record again!
110
  """)
111
  with gr.Row():
112
  with gr.Column():
@@ -120,5 +124,9 @@ with demo:
120
  #out_generated_text_en = gr.Textbox(label= 'AI response to your query in English using Bloom! ')
121
 
122
  b1.click(driver_fun,inputs=[in_audio], outputs=[out_transcript, out_generated_joke, out_audio]) #out_translation_en, out_generated_text,out_generated_text_en,
123
-
 
 
 
 
124
  demo.launch(enable_queue=True, debug=True)
 
10
  import random
11
 
12
  dataset = load_dataset("ysharma/short_jokes", split="train")
13
+ filtered_dataset = dataset.filter(
14
+ lambda x: (True not in [nsfw in x["Joke"].lower() for nsfw in ["warning", "fuck", "dead", "nsfw","69", "sex"]])
15
+ )
16
+
17
 
18
  # Model 2: Sentence Transformer
19
  API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/msmarco-distilbert-base-tas-b"
 
51
  lower_limit = random_val - 5000
52
  upper_limit = random_val
53
  print(f"lower_limit : upper_limit = {lower_limit} : {upper_limit}")
54
+ dataset_subset = filtered_dataset['Joke'][lower_limit : upper_limit]
55
  data = query({"inputs": {"source_sentence": "That is a happy person","sentences": dataset_subset} } )
56
  if 'error' in data:
57
  print(f"Error is : {data}")
 
110
  with demo:
111
  gr.Markdown("<h1><center>AI Assistant - Voice to Joke</center></h1>")
112
  gr.Markdown(
113
+ """This is still a work in porgress<br><br>Ask Whisper for a joke about anything you would wish.
114
  """)
115
  with gr.Row():
116
  with gr.Column():
 
124
  #out_generated_text_en = gr.Textbox(label= 'AI response to your query in English using Bloom! ')
125
 
126
  b1.click(driver_fun,inputs=[in_audio], outputs=[out_transcript, out_generated_joke, out_audio]) #out_translation_en, out_generated_text,out_generated_text_en,
127
+ with gr.Row():
128
+ gr.Markdown(
129
+ """Model pipeline consisting of - <br>- [**Whisper**](https://github.com/openai/whisper) for Speech-to-text, <br>- [**CoquiTTS**](https://huggingface.co/coqui) for Text-To-Speech. <br>- Front end is built using [**Gradio Block API**](https://gradio.app/docs/#blocks).<br><be>If you want to reuse the App, simply click on the small cross button in the top right corner of your voice record panel, and then press record again!
130
+ """)
131
+
132
  demo.launch(enable_queue=True, debug=True)