Android ilbc 语音对话示范(二)代码搭建

 

基于上一篇中提到的google网站的一份代码,这个需要git下载,我上传了一份在CSDN,进行了修改,并且有很多人一直来找我问一些问题,很抱

歉都没有认真回复大家,现在打算继续把这个项目做下去,所以代码统一放到了Github上面来管理,以后会持续更新,代码地址是 Android-iLbc


现在开始讲解代码结构搭建环节:

要求:
环境:Ubuntu 12.04 (其他Linux环境皆可),Android 2.2 及以上系统

工具:Elicpse 3.7 ,Android NDK r7 ,Android SDK

1.新建工程:

打开Eclipse,新建一个Android 程序,名称为 AndroidILBC 


2.添加底层代码:

     将下载的源码中的 jni 文件夹复制到新建的工程的根目录下,此时,代码结构如下:

                              


3.Android.mk编写:

LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
 LOCAL_MODULE := libilbc
 
 codec_dir := iLBC_RFC3951  #ilbc 源代码的目录
 
 LOCAL_SRC_FILES := \
     $(codec_dir)/anaFilter.c \
     $(codec_dir)/constants.c \
     $(codec_dir)/createCB.c \
     $(codec_dir)/doCPLC.c \
     $(codec_dir)/enhancer.c \
     $(codec_dir)/filter.c \
     $(codec_dir)/FrameClassify.c \
     $(codec_dir)/gainquant.c \
     $(codec_dir)/getCBvec.c \
     $(codec_dir)/helpfun.c \
     $(codec_dir)/hpInput.c \
     $(codec_dir)/hpOutput.c \
     $(codec_dir)/iCBConstruct.c \
     $(codec_dir)/iCBSearch.c \
     $(codec_dir)/iLBC_decode.c \
     $(codec_dir)/iLBC_encode.c \
     $(codec_dir)/LPCdecode.c \
     $(codec_dir)/LPCencode.c \
     $(codec_dir)/lsf.c \
     $(codec_dir)/packing.c \
     $(codec_dir)/StateConstructW.c \
     $(codec_dir)/StateSearchW.c \
     $(codec_dir)/syntFilter.c
 
 LOCAL_C_INCLUDES += $(common_C_INCLUDES)
 
 LOCAL_PRELINK_MODULE := false
 
 include $(BUILD_STATIC_L
  • 17
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
iLBC (internet Low Bitrate Codec) is a speech codec used for encoding and decoding speech signals. To decode an iLBC-encoded audio file, you can use a decoder library or tool that supports iLBC decoding. Here is an example of how you can decode an iLBC file using the libilbc library in C: 1. Install the libilbc library on your system. 2. Include the necessary header files in your C code: ```c #include <stdio.h> #include <stdlib.h> #include <ilbc/ilbc.h> ``` 3. Write a function to perform the iLBC decoding: ```c void ilbc_decode(const char* input_file, const char* output_file) { FILE* fin = fopen(input_file, "rb"); FILE* fout = fopen(output_file, "wb"); // Get input file size fseek(fin, 0, SEEK_END); long input_size = ftell(fin); rewind(fin); // Allocate memory for input and output buffers int16_t* input_buffer = (int16_t*)malloc(input_size); int16_t* output_buffer = (int16_t*)malloc(input_size * 2); // Double the size for stereo audio // Read the input file into the input buffer fread(input_buffer, sizeof(int16_t), input_size / sizeof(int16_t), fin); // Create an iLBC decoder instance iLBC_Dec_Inst_t* dec_inst = iLBC_create(1); // 1 for 20ms frame size // Perform the decoding int num_frames = input_size / (2 * sizeof(int16_t)); // Assuming mono audio, 2 bytes per sample iLBC_decode(dec_inst, input_buffer, num_frames, output_buffer); // Write the decoded audio to the output file fwrite(output_buffer, sizeof(int16_t), num_frames * sizeof(int16_t), fout); // Cleanup fclose(fin); fclose(fout); free(input_buffer); free(output_buffer); iLBC_free(dec_inst); } ``` 4. Call the `ilbc_decode` function with the input and output file paths: ```c int main() { const char* input_file = "encoded.ilbc"; const char* output_file = "decoded.pcm"; ilbc_decode(input_file, output_file); return 0; } ``` Make sure to replace "encoded.ilbc" with the path to your iLBC-encoded file and "decoded.pcm" with the desired output file path. After running the program, you should have the decoded audio in the output file. Please note that this is just a basic example, and you may need to modify it according to your specific requirements and the iLBC decoder library you are using.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值