Cahya Wirawan commited on
Commit
7191ca8
1 Parent(s): 64977d2

move to Dockerfile

Browse files
Dockerfile ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu18.04
2
+ RUN useradd -m -u 1000 user
3
+ WORKDIR /home/user/app
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+ RUN apt-get update && apt-get install -y \
6
+ git make build-essential zlib1g-dev \
7
+ libsqlite3-dev wget llvm libncursesw5-dev xz-utils tk-dev libxml2-dev \
8
+ libxmlsec1-dev libffi-dev liblzma-dev git-lfs ffmpeg libsm6 libxext6 cmake \
9
+ libgl1-mesa-glx curl nginx espeak-ng openssl libssl-dev libbz2-dev \
10
+ libncurses5-dev libreadline-dev \
11
+ && rm -rf /var/lib/apt/lists/* && git lfs install
12
+
13
+ RUN chown -R 1000 /var/log/nginx/ /var/lib/nginx/ /run/
14
+ USER user
15
+ ENV HOME /home/user
16
+ ENV PYENV_ROOT $HOME/.pyenv
17
+ ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
18
+
19
+
20
+ RUN git clone https://github.com/yyuu/pyenv.git $HOME/.pyenv
21
+ #RUN curl https://pyenv.run | bash && \
22
+ RUN pyenv install 3.8.9 && pyenv global 3.8.9 && pyenv rehash && \
23
+ pip install --no-cache-dir --upgrade pip setuptools wheel && \
24
+ pip install --no-cache-dir datasets huggingface-hub "protobuf<4" "click<8.1"
25
+ COPY --chown=user:user ./requirements.txt /home/user/requirements.txt
26
+ RUN pip install --no-cache-dir --upgrade -r /home/user/requirements.txt
27
+ COPY --chown=user:user ./app /home/user/app
28
+ COPY ./default /etc/nginx/sites-available
29
+ EXPOSE 7860
30
+ CMD ["/bin/sh", "/home/user/app/start.sh"]
README.md CHANGED
@@ -3,10 +3,9 @@ title: Indonesian Whisperer
3
  emoji: 🇮🇩
4
  colorFrom: purple
5
  colorTo: red
6
- sdk: gradio
7
- sdk_version: 3.15.0
8
- app_file: app.py
9
  pinned: true
 
10
  tags:
11
  - whisper-event
12
  ---
 
3
  emoji: 🇮🇩
4
  colorFrom: purple
5
  colorTo: red
6
+ sdk: docker
 
 
7
  pinned: true
8
+ license: cc
9
  tags:
10
  - whisper-event
11
  ---
{data → app/data}/JFK.mp3 RENAMED
File without changes
{data → app/data}/Jokowi - 2022.mp3 RENAMED
File without changes
{data → app/data}/Soekarno - 1963.mp3 RENAMED
File without changes
app/start.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ cd /home/user/app
5
+
6
+ id
7
+ ls -ld /var/log/nginx/ /var/lib/nginx/ /run
8
+ ls -la /
9
+ ls -la ~
10
+
11
+ nginx
12
+
13
+ python whisper.py&
14
+
15
+ if [ "$DEBUG" = true ] ; then
16
+ echo 'Debugging - ON'
17
+ uvicorn web_socket:app --host 0.0.0.0 --port 7880 --reload
18
+ else
19
+ echo 'Debugging - OFF'
20
+ uvicorn web_socket:app --host 0.0.0.0 --port 7880
21
+ echo $?
22
+ echo END
23
+ fi
app/web_socket.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, WebSocket
2
+ from fastapi.responses import HTMLResponse
3
+ import os
4
+
5
+
6
+ app = FastAPI()
7
+
8
+ html = """
9
+ <!DOCTYPE html>
10
+ <html>
11
+ <head>
12
+ <title>Chat</title>
13
+ </head>
14
+ <body>
15
+ <h1>WebSocket Chat</h1>
16
+ <form action="" onsubmit="sendMessage(event)">
17
+ <input type="text" id="messageText" autocomplete="off"/>
18
+ <button>Send</button>
19
+ </form>
20
+ <ul id='messages'>
21
+ </ul>
22
+ <script>
23
+ // var ws = new WebSocket("ws://localhost:8000/api/ws");
24
+ var ws = new WebSocket("wss://cahya-indonesian-whisperer.hf.space/api/ws");
25
+ ws.onmessage = function(event) {
26
+ var messages = document.getElementById('messages')
27
+ var message = document.createElement('li')
28
+ var content = document.createTextNode(event.data)
29
+ message.appendChild(content)
30
+ messages.appendChild(message)
31
+ };
32
+ function sendMessage(event) {
33
+ var input = document.getElementById("messageText")
34
+ ws.send(input.value)
35
+ input.value = ''
36
+ event.preventDefault()
37
+ }
38
+ </script>
39
+ </body>
40
+ </html>
41
+ """
42
+
43
+
44
+ @app.get("/")
45
+ async def get():
46
+ return HTMLResponse(html)
47
+
48
+ @app.get("/env")
49
+ async def env():
50
+ environment_variables = "<h3>Environment Variables</h3>"
51
+ for name, value in os.environ.items():
52
+ environment_variables += f"{name}: {value}<br>"
53
+ return HTMLResponse(environment_variables)
54
+
55
+ @app.websocket("/ws")
56
+ async def websocket_endpoint(websocket: WebSocket):
57
+ await websocket.accept()
58
+ while True:
59
+ data = await websocket.receive_text()
60
+ await websocket.send_text(f"Message text was: {data}")
61
+
app.py → app/whisper.py RENAMED
File without changes
default ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##
2
+ # You should look at the following URL's in order to grasp a solid understanding
3
+ # of Nginx configuration files in order to fully unleash the power of Nginx.
4
+ # https://www.nginx.com/resources/wiki/start/
5
+ # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
6
+ # https://wiki.debian.org/Nginx/DirectoryStructure
7
+ #
8
+ # In most cases, administrators will remove this file from sites-enabled/ and
9
+ # leave it as reference inside of sites-available where it will continue to be
10
+ # updated by the nginx packaging team.
11
+ #
12
+ # This file will automatically load configuration files provided by other
13
+ # applications, such as Drupal or Wordpress. These applications will be made
14
+ # available underneath a path with that package name, such as /drupal8.
15
+ #
16
+ # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
17
+ ##
18
+
19
+ # Default server configuration
20
+ #
21
+ server {
22
+ listen 7860 default_server;
23
+ listen [::]:7860 default_server;
24
+
25
+ # SSL configuration
26
+ #
27
+ # listen 443 ssl default_server;
28
+ # listen [::]:443 ssl default_server;
29
+ #
30
+ # Note: You should disable gzip for SSL traffic.
31
+ # See: https://bugs.debian.org/773332
32
+ #
33
+ # Read up on ssl_ciphers to ensure a secure configuration.
34
+ # See: https://bugs.debian.org/765782
35
+ #
36
+ # Self signed certs generated by the ssl-cert package
37
+ # Don't use them in a production server!
38
+ #
39
+ # include snippets/snakeoil.conf;
40
+
41
+ root /var/www/html;
42
+
43
+ # Add index.php to the list if you are using PHP
44
+ index index.html index.htm index.nginx-debian.html;
45
+
46
+ server_name _;
47
+
48
+ location / {
49
+ proxy_set_header Host $host;
50
+ proxy_set_header X-Real-IP $remote_addr;
51
+ proxy_pass http://localhost:7870;
52
+ }
53
+
54
+ location /api/ {
55
+ proxy_set_header Host $host;
56
+ proxy_set_header X-Real-IP $remote_addr;
57
+ proxy_pass http://localhost:7880/;
58
+
59
+ proxy_http_version 1.1;
60
+ proxy_set_header Upgrade $http_upgrade;
61
+ proxy_set_header Connection "upgrade";
62
+ }
63
+
64
+
65
+ # pass PHP scripts to FastCGI server
66
+ #
67
+ #location ~ \.php$ {
68
+ # include snippets/fastcgi-php.conf;
69
+ #
70
+ # # With php-fpm (or other unix sockets):
71
+ # fastcgi_pass unix:/run/php/php7.4-fpm.sock;
72
+ # # With php-cgi (or other tcp sockets):
73
+ # fastcgi_pass 127.0.0.1:9000;
74
+ #}
75
+
76
+ # deny access to .htaccess files, if Apache's document root
77
+ # concurs with nginx's one
78
+ #
79
+ #location ~ /\.ht {
80
+ # deny all;
81
+ #}
82
+ }
83
+
84
+
85
+ # Virtual Host configuration for example.com
86
+ #
87
+ # You can move that to a different file under sites-available/ and symlink that
88
+ # to sites-enabled/ to enable it.
89
+ #
90
+ #server {
91
+ # listen 80;
92
+ # listen [::]:80;
93
+ #
94
+ # server_name example.com;
95
+ #
96
+ # root /var/www/example.com;
97
+ # index index.html;
98
+ #
99
+ # location / {
100
+ # try_files $uri $uri/ =404;
101
+ # }
102
+ #}
requirements.txt CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  git+https://github.com/huggingface/transformers
2
  torch
3
  neon-tts-plugin-coqui==0.6.0
 
1
+ gradio
2
+ fastapi
3
+ pydantic
4
+ uvicorn
5
+ websockets
6
  git+https://github.com/huggingface/transformers
7
  torch
8
  neon-tts-plugin-coqui==0.6.0