• Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LingoRecorder is a better recorder for Android, you can easily process pcm from it.

LingoRecorder

LingoRecord is a better recorder for Android, you can easily process pcm data from it.

Download

Features

  1. 多线程机制保证处理能力和 PCM 数据的完整性。

  2. 抽象出 AudioProcessor 来注入 Recorder 中以支持录音和处理的分离。

  3. 提供 WavFileRecorder 以支持以文件来替代录音器生成录音数据。

  4. 提供 aidl 接口方便在另一个进程中处理录音数据。

Sample

LingoRecorder 的使用

只需简单的三步操作即可:

lingoRecorder = new LingoRecorder();
lingoRecorder.setOnRecordStopListener(new LingoRecorder.OnRecordStopListener() {
    @Override
    public void onRecordStop(Throwable throwable,
        Result result) {
        //any execeptions occur during recording will be received at here.
        //you can get duration and output file from Result.
    }
});
lingoRecorder.setOnProcessStopListener(new LingoRecorder.OnProcessStopListener() {
    @Override
    public void onProcessStop(Throwable throwable, Map<String, AudioProcessor> map) {
        //any execeptions occur during processing will be received at here.
        //you can get any processors you inject into recorder.
        //the callback will be invoked after "onRecordStop".
    }
});

效果图:

image

自定义 AudioProcessor 的使用

可以实现 AudioProcessor 来自定义自己的处理器:

public interface AudioProcessor {

    void start() throws Exception;

    void flow(byte[] bytes, int size) throws Exception;

    boolean needExit();

    void end() throws Exception;

    void release();

}

效果图:

image

将 AudioProcessor 运行在一个独立的进程中

LingoRecorder 提供了 aidl 接口以支持在一个独立的进程中运行 AudioProcessor。示例中自定义了一个 LocalScorerProcessor 运行在 "score" 进程中。

Flac encoder

示例中也演示了一个使用 MediaCodec 进行 Flac 编码的 AudioProcessor。此示例是为了向有硬编码需求的用户提供一个样例。

计算/监听音量

设置音量监听器:

//只设置 OnVolumeListener 的时候,计算音量的方式使用的是一个默认的内部实现
//内部默认实现的返回值是[0, 90]的分贝值
lingoRecorder.setOnVolumeListener(new OnVolumeListener() {
	@Override
	public void onVolume(double volume) {

	}
});
//也可以提供自己的计算音量的实现
lingoRecorder.setOnVolumeListener(new OnVolumeListener() {
	@Override
	public void onVolume(double volume) {

	}
}, new IVolumeCalculator() {
	@Override
	public double onAudioChunk(byte[] chunk, int size, int bitsPerSample) {
		return 0;
	}
});

Demo 中提供了相关示例,效果图:

image

在项目中引用

Gradle:

compile 'com.liulishuo.engzo:lingo-recorder:1.2.5'

Pull Request

欢迎各位基于 develop 分支进行 pull request。

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

FileDownloader

Multitask、MultiThread(MultiConnection)、Breakpoint-resume、High-concurrency、Simple to use、Single/NotSingle-process
Java
11,031
star
2

okdownload

A Reliable, Flexible, Fast and Powerful download engine.
Java
5,178
star
3

MagicProgressWidget

MagicProgressCircle & MagicProgressBar
Java
728
star
4

ShareLoginLib

ThirdParty login and share lib
Java
702
star
5

Diplomat

整合第三方 SDK 微信、微博、 QQ 等为统一的 Diplomat 接口。
Objective-C
661
star
6

QiniuImageLoader

在Android上结合七牛提供的API,让加载图片更有效、更节流、更简单、更可控、更酷
Java
524
star
7

okcheck

Incremental scan,integrate Lint、KtLint、UnitTest、Checkstyle、Findbugs、Pmd, powerful and easy to use
Groovy
309
star
8

FuriganaTextView

A simple wrapper view for UITextView that can display Furiganas.
Swift
133
star
9

SpanEllipsizeEnd

处理 Span 在 最大宽度文字尾省略号,无效的问题。
Java
89
star
10

Multi-Scale-BERT-AES

Demo for the paper "On the Use of BERT for Automated Essay Scoring: Joint Learning of Multi-Scale Essay Representation"
Python
56
star
11

tensorflow-dkt

Build DKT (Deep Knowledge Tracing) model with TensorFlow
Python
47
star
12

OnlineScorer-Wechat

流利说在线录音打分微信版SDK
JavaScript
37
star
13

OnlineScorer-Android

C
12
star
14

OnlineScorer-iOS

OnlineScorerRecorder for iOS
Objective-C
9
star
15

Mercury

Kotlin
9
star
16

OnlineScorer-Web

JavaScript
6
star
17

open-asr

Python
5
star
18

language-coursescript

Syntax highlighting and snippets for CourseScript.
CoffeeScript
3
star
19

open-wechat-scorer

Server-side SDK for Liulishuo Open Platform
Python
1
star
20

PTSDK-iOS

PTSDK Framework for iOS
Swift
1
star
21

cares

A forked c-ares repository to make GRPC compilation less painful
C
1
star