Skip to content

Commit

Permalink
删除对于8000采样率的描述
Browse files Browse the repository at this point in the history
  • Loading branch information
authorfu committed Mar 5, 2018
1 parent 1a36b3f commit 7124424
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 51 deletions.
11 changes: 3 additions & 8 deletions rest-api-asr/bash_shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ FILE="16k_test.pcm"

# 根据文件FILE的后缀填写:pcm/wav/amr
FORMAT="pcm"
# 根据文件FILE的采样率填写:16000/8000
RATE="16000"

# 根据文档填写PID,1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型
DEV_PID="1537"
```
Expand All @@ -70,18 +67,16 @@ DEV_PID="1537"
1. 如测试英语 修改为:

```bash
DEV_PID="1637"
DEV_PID="1737"
```

2. 如测试采样率为8k 的amr文件8k-122.amr,修改为:
2. 如测试采样率为16k 的amr文件16k-23850.amr,修改为:

```bash
FILE="8k-122.amr"
FILE="16k-23850.amr"

# 根据文件FILE的后缀填写:pcm/wav/amr
FORMAT="amr"
# 根据文件FILE的采样率填写:16000/8000
RATE="8000"
```

3 changes: 1 addition & 2 deletions rest-api-asr/bash_shell/asr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ FILE="16k_test.pcm"

# 根据文件FILE的后缀填写:pcm/wav/amr
FORMAT="pcm"
# 根据文件FILE的采样率填写:16000/8000
RATE="16000"

# 根据文档填写PID,1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型
DEV_PID="1537"
Expand All @@ -27,6 +25,7 @@ fi
CUID="1234567"
URL="http://vop.baidu.com/server_api?dev_pid=${DEV_PID}&token=$TOKEN&cuid=$CUID"

RATE="16000" // 固定值
HEADER="Content-Type: audio/$FORMAT;rate=$RATE";

#curl -i -X POST -k "$CURL_OPT" --data-binary "@$FILE" "$URL"
Expand Down
11 changes: 3 additions & 8 deletions rest-api-asr/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ private final String filename = "16k_test.pcm";
// 文件格式
private final String format = "pcm";

// 采样率
private final int rate = 16000;

// 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型。 其它语种参见文档
private final int dev_pid = 1537;
```
Expand All @@ -66,20 +63,18 @@ private final int dev_pid = 1537;
1. 如测试英语 修改为:

```bash
$dev_pid = 1637;
$dev_pid = 1737;
```

2. 如测试采样率为8k 的amr文件8k-122.amr,修改为:
2. 如测试采样率为16k 的amr文件16k-23850.amr,修改为:

```java
// 需要识别的文件
private final String filename = "8k-122.amr";
private final String filename = "16k-23850.amr";

// 文件格式
private final String format = "amr";

// 采样率
private final int rate = 8000;
```

Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public static void main(String[] args) throws IOException, DemoException {
// 文件格式
private final String format = "pcm";

// 采样率
private final int rate = 16000;

// 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型。 其它语种参见文档
private final int dev_pid = 1537;

private String cuid = "1234567JAVA";


// 采样率固定值
private final int rate = 16000;

public boolean methodRaw = false; // 默认以json方式上传音频文件

private final String url = "http://vop.baidu.com/server_api"; // 可以改为https
Expand Down
11 changes: 4 additions & 7 deletions rest-api-asr/linux_c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ static RETURN_CODE fill_config(struct asr_config *config) {
char *filename = "16k_test.pcm";
// 文件后缀 pcm/wav/amr ,不支持其它格式
char format[] = "pcm";
// 采样率16000或者 8000
int rate = 16000;
// 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型 其它语种参见文档
int dev_pid = 1537;
```
Expand All @@ -90,18 +89,16 @@ static RETURN_CODE fill_config(struct asr_config *config) {
1. 如测试英语 修改为:

```c
int dev_pid = 1637;
int dev_pid = 1737;
```

2. 如测试采样率为8k 的amr文件8k-122.amr,修改为:
2. 如测试采样率为16k 的amr文件16k-23850.amr,修改为:

```c
// 需要识别的文件
char *filename = "8k-122.amr";
char *filename = "16k-23850.amr";
// 文件后缀 pcm/wav/amr ,不支持其它格式
char format[] = "amr";
// 采样率16000或者 8000
int rate = 8000;
```

5 changes: 2 additions & 3 deletions rest-api-asr/linux_c/asrmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ static RETURN_CODE fill_config(struct asr_config *config) {
}
// 文件后缀 pcm/wav/amr ,不支持其它格式
char format[] = "pcm";
// 采样率16000或者 8000
int rate = 16000;

// 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型 其它语种参见文档
int dev_pid = 1537;

Expand All @@ -37,7 +36,7 @@ static RETURN_CODE fill_config(struct asr_config *config) {
snprintf(config->secret_key, sizeof(config->secret_key), "%s", secret_key);
config->file = fp;
snprintf(config->format, sizeof(config->format), "%s", format);
config->rate = rate;
config->rate = 16000; // 采样率固定值
config->dev_pid = dev_pid;
snprintf(config->cuid, sizeof(config->cuid), "1234567C");

Expand Down
10 changes: 4 additions & 6 deletions rest-api-asr/linux_c/build_and_asr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
#需要预先安装libcurl库,安装方法见README.md

GCC=gcc
#OPT="-std=gnu99"
OPT=""
MAIN_SOURCE=asrmain

$GCC --version && \
rm -rf $MAIN_SOURCE build && \
mkdir -p build && cd build && \
#$GCC -I../thirdparty/include -I.. -g $OPT -o token.o -c ../token.c && \
#$GCC -I../thirdparty/include -I.. -g $OPT 9 -o common.o -c ../common.c && \
#$GCC -I../thirdparty/include -I.. -g $OPT -o $MAIN_SOURCE.o -c ../$MAIN_SOURCE.c && \
#$GCC -I../thirdparty/include -I.. -g -std=gnu99 -o token.o -c ../token.c && \
#$GCC -I../thirdparty/include -I.. -g -std=gnu99 -o common.o -c ../common.c && \
#$GCC -I../thirdparty/include -I.. -g -std=gnu99 -o $MAIN_SOURCE.o -c ../$MAIN_SOURCE.c && \
#$GCC -g *.o -L../thirdparty/lib -lcurl -o $MAIN_SOURCE
$GCC -g -I../thirdparty/include -I.. $OPT ../token.c ../common.c ../$MAIN_SOURCE.c -L../thirdparty/lib -lcurl -o $MAIN_SOURCE && \
$GCC -g -I../thirdparty/include -I.. -std=gnu99 ../token.c ../common.c ../$MAIN_SOURCE.c -L../thirdparty/lib -lcurl -o $MAIN_SOURCE && \
mv $MAIN_SOURCE .. && \
echo "build success ,wait 3s to run" && \
sleep 3 &&\
Expand Down
11 changes: 4 additions & 7 deletions rest-api-asr/php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ windows 下可能产生乱码,请打开result.txt
$audio_file = "./16k.pcm";
# 文件格式
$format = "pcm"; // 文件后缀 pcm/wav/amr
# 采样率
$rate = 16000; // 采样率16000或者 8000
# 根据文档填写PID,选择语言及识别模型
$dev_pid = 1537; // 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型
```
Expand All @@ -65,18 +63,17 @@ $dev_pid = 1537; // 1537 表示识别普通话,使用输入法模型。1536
1. 如测试英语 修改为:

```bash
$dev_pid = 1637;
$dev_pid = 1737;
```

2. 如测试采样率为8k 的amr文件8k-122.amr,修改为:
2. 如测试采样率为16k 的amr文件16k-23850.amr,修改为:

```bash
# 需要识别的文件
$audio_file = "./8k-122.amr";
$audio_file = "./16k-23850.amr";
# 文件格式
$format = "amr"; // 文件后缀 pcm/wav/amr
# 采样率
$rate = 8000; // 采样率16000或者 8000

```

6 changes: 3 additions & 3 deletions rest-api-asr/php/asr_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
$audio_file = "./16k.pcm";
# 文件格式
$format = "pcm"; // 文件后缀 pcm/wav/amr
# 采样率
$rate = 16000; // 采样率16000或者 8000

# 根据文档填写PID,选择语言及识别模型
$dev_pid = 1537; // 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型

$cuid = "123456PHP";

# 采样率
$rate = 16000; // 固定值
/** 公共模块获取token开始 */

$auth_url = "https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=".$apiKey."&client_secret=".$secretKey;
Expand Down
6 changes: 3 additions & 3 deletions rest-api-asr/php/asr_raw.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
$audio_file = "./16k.pcm";
# 文件格式
$format = "pcm"; // 文件后缀 pcm/wav/amr
# 采样率
$rate = 16000; // 采样率16000或者 8000

# 根据文档填写PID,选择语言及识别模型
$dev_pid = 1537; // 1537 表示识别普通话,使用输入法模型。1536表示识别普通话,使用搜索模型 其它语种参见文档

$cuid = "123456PHP";

# 采样率
$rate = 16000; // 采样率16000固定值
/** 公共模块获取token开始 */

$auth_url = "https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=".$apiKey."&client_secret=".$secretKey;
Expand Down

0 comments on commit 7124424

Please sign in to comment.