fasdfsa commited on
Commit
fbd23c5
·
1 Parent(s): fb7f2da

server.bat

Browse files
Files changed (3) hide show
  1. post.py +40 -0
  2. server.bat +19 -0
  3. server.sh +17 -0
post.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import os
4
+
5
+ url = "http://127.0.0.1:8081/inference"
6
+
7
+ # 音频文件路径,根据 readme.txt #L23,这里以 60s.wav 为例
8
+ audio_file = "/root/huggingface_echodict/KotobaASRLLM/KotobaASRLLM/60s.wav"
9
+
10
+ if not os.path.exists(audio_file):
11
+ print(f"找不到音频文件: {audio_file}")
12
+ exit(1)
13
+
14
+ # 构建 multipart/form-data 数据
15
+ # 使用 language = ja,对应 -l ja
16
+ # response_format 设为 json,对应 --output-json
17
+ data = {
18
+ "temperature": "0.0",
19
+ "language": "ja",
20
+ "response_format": "json"
21
+ }
22
+
23
+ print(f"正在发送请求到 {url}...")
24
+ print(f"音频文件: {audio_file}")
25
+
26
+ with open(audio_file, "rb") as f:
27
+ files = {"file": (os.path.basename(audio_file), f, "audio/wav")}
28
+ try:
29
+ response = requests.post(url, data=data, files=files)
30
+ response.raise_for_status()
31
+
32
+ # 尝试解析返回的 JSON 数据
33
+ result = response.json()
34
+ print("\n识别结果 (JSON格式):")
35
+ print(json.dumps(result, indent=2, ensure_ascii=False))
36
+
37
+ except requests.exceptions.RequestException as e:
38
+ print(f"\n请求失败: {e}")
39
+ if e.response is not None:
40
+ print(f"服务器返回内容: {e.response.text}")
server.bat ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ setlocal enabledelayedexpansion
3
+
4
+ REM 获取当前脚本所在目录
5
+ set "SCRIPT_DIR=%~dp0"
6
+ set "BASE_DIR=%SCRIPT_DIR%KotobaASRLLM"
7
+ set "SERVER_PATH=%BASE_DIR%\whisper-server.exe"
8
+ set "MODEL_PATH=%BASE_DIR%\ggml-kotoba-whisper-v2.0.bin"
9
+
10
+ echo 启动 whisper-server 服务...
11
+ echo 执行命令: "%SERVER_PATH%" -m "%MODEL_PATH%" --host 127.0.0.1 --port 8081 --convert
12
+ echo 服务将运行在 http://127.0.0.1:8081/inference
13
+
14
+ "%SERVER_PATH%" -m "%MODEL_PATH%" --host 127.0.0.1 --port 8081 --convert
15
+
16
+ if %errorlevel% neq 0 (
17
+ echo 服务启动失败或异常退出,错误码: %errorlevel%
18
+ pause
19
+ )
server.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # 配置路径
4
+ BASE_DIR="/root/huggingface_echodict/KotobaASRLLM/KotobaASRLLM"
5
+ SERVER_PATH="${BASE_DIR}/whisper-server"
6
+ MODEL_PATH="${BASE_DIR}/ggml-kotoba-whisper-v2.0.bin"
7
+
8
+ echo "启动 whisper-server 服务..."
9
+ echo "执行命令: ${SERVER_PATH} -m ${MODEL_PATH} --host 127.0.0.1 --port 8081 --convert"
10
+ echo "服务将运行在 http://127.0.0.1:8081/inference"
11
+
12
+ # 启动进程并替换当前 shell 进程
13
+ exec "${SERVER_PATH}" \
14
+ -m "${MODEL_PATH}" \
15
+ --host "127.0.0.1" \
16
+ --port "8081" \
17
+ --convert