日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

pythonint函数的参数_向嵌入的Python函数传递两个参数(int和array)

發(fā)布時間:2025/3/11 python 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pythonint函数的参数_向嵌入的Python函数传递两个参数(int和array) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我需要從我的模塊中調(diào)用Python函數(shù)并為其設(shè)置兩個參數(shù):int和array。在

現(xiàn)在我在調(diào)用這個函數(shù)的時候遇到了segfault,我不知道我做錯了什么。有人能指出我的錯誤在哪里嗎?在

函數(shù)在我的Python模塊中應(yīng)用程序副本. 如果我從Python代碼調(diào)用它,它會起作用:def get_model(rate, signal):

mfcc_train = MFCC().compute(rate, signal)

with open('mfcc_test', 'wb') as f:

pickle.dump(mfcc_train, f)

return clf()._fit(mfcc_train)

調(diào)用上面函數(shù)的C代碼。最后一個春天是“打電話前”

^{pr2}$

UPD:更新代碼,其中一個問題已修復(fù)。但另一個問題仍然存在。它在PyObject* pSamples = PyArray_SimpleNewFromData(1, dims, NPY_INT8, (void*)samples);行。我也不知道是怎么回事。在

和wav.h以防萬一:#include

#include

#include

#include

#include

#include

typedef struct {

char chunk_id[4];

uint32_t chunk_size;

char format[4];

char fmtchunk_id[4];

uint32_t fmtchunk_size;

uint16_t audio_format;

uint16_t num_channels;

uint32_t sample_rate;

uint32_t byte_rate;

uint16_t block_align;

uint16_t bps;

char datachunk_id[4];

uint32_t datachunk_size;

}WavHeader;

WavHeader *header;

void wavread(char *file_name, int16_t **samples)

{

int fd;

if (!file_name)

errx(1, "Filename not specified");

if ((fd = open(file_name, O_RDONLY)) < 1)

errx(1, "Error opening file");

if (!header)

header = (WavHeader*)malloc(sizeof(WavHeader));

if (read(fd, header, sizeof(WavHeader)) < sizeof(WavHeader))

errx(1, "File broken: header");

if (strncmp(header->chunk_id, "RIFF", 4) ||

strncmp(header->format, "WAVE", 4))

errx(1, "Not a wav file");

if (header->audio_format != 1)

errx(1, "Only PCM encoding supported");

if (*samples) free(*samples);

*samples = (int16_t*)malloc(header->datachunk_size);

if (!*samples)

errx(1, "Error allocating memory");

if (read(fd, *samples, header->datachunk_size) < header->datachunk_size)

errx(1, "File broken: samples");

close(fd);

}

總結(jié)

以上是生活随笔為你收集整理的pythonint函数的参数_向嵌入的Python函数传递两个参数(int和array)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。