Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import os, json
|
|
| 9 |
from sys import argv
|
| 10 |
from vllm import LLM, SamplingParams
|
| 11 |
import vllm
|
|
|
|
| 12 |
|
| 13 |
from huggingface_hub import login
|
| 14 |
TOKEN = os.environ.get("TOKEN", None)
|
|
@@ -80,8 +81,18 @@ def response_to_audio(audio_url, text, model=None, processor=None, temperature =
|
|
| 80 |
def clear_inputs():
|
| 81 |
return None, "", ""
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
def compare_responses(audio_url, text):
|
|
|
|
|
|
|
|
|
|
| 84 |
response1 = response_to_audio(audio_url, text, model1, processor1)
|
|
|
|
|
|
|
| 85 |
return response1
|
| 86 |
|
| 87 |
with gr.Blocks() as demo:
|
|
@@ -107,7 +118,7 @@ with gr.Blocks() as demo:
|
|
| 107 |
gr.HTML(
|
| 108 |
"""<div style="text-align: center; font-size: 16px;">
|
| 109 |
This WebUI is based on <a href="https://huggingface.co/SeaLLMs/SeaLLMs-Audio-7B">SeaLLMs-Audio-7B</a>, developed by Alibaba DAMO Academy.<br>
|
| 110 |
-
You can interact with the chatbot in <b>English,
|
| 111 |
For the input, you can provide <b>audio and/or text</b>.
|
| 112 |
</div>"""
|
| 113 |
)
|
|
|
|
| 9 |
from sys import argv
|
| 10 |
from vllm import LLM, SamplingParams
|
| 11 |
import vllm
|
| 12 |
+
import re
|
| 13 |
|
| 14 |
from huggingface_hub import login
|
| 15 |
TOKEN = os.environ.get("TOKEN", None)
|
|
|
|
| 81 |
def clear_inputs():
|
| 82 |
return None, "", ""
|
| 83 |
|
| 84 |
+
def contains_chinese(text):
|
| 85 |
+
# Regular expression for Chinese characters
|
| 86 |
+
chinese_char_pattern = re.compile(r'[\u4e00-\u9fff]')
|
| 87 |
+
return bool(chinese_char_pattern.search(text))
|
| 88 |
+
|
| 89 |
def compare_responses(audio_url, text):
|
| 90 |
+
if contains_chinese:
|
| 91 |
+
return "Caution! This demo does not support Chinese!"
|
| 92 |
+
|
| 93 |
response1 = response_to_audio(audio_url, text, model1, processor1)
|
| 94 |
+
return "ERROR! Try another example!"
|
| 95 |
+
|
| 96 |
return response1
|
| 97 |
|
| 98 |
with gr.Blocks() as demo:
|
|
|
|
| 118 |
gr.HTML(
|
| 119 |
"""<div style="text-align: center; font-size: 16px;">
|
| 120 |
This WebUI is based on <a href="https://huggingface.co/SeaLLMs/SeaLLMs-Audio-7B">SeaLLMs-Audio-7B</a>, developed by Alibaba DAMO Academy.<br>
|
| 121 |
+
You can interact with the chatbot in <b>English, Indonesian, Thai, or Vietnamese</b>.<br>
|
| 122 |
For the input, you can provide <b>audio and/or text</b>.
|
| 123 |
</div>"""
|
| 124 |
)
|