在tensorflow js中播放原始音频数据

问题描述

我有一个基于博客的tensorflow.js的音频分类器。

https://codelabs.developers.google.com/codelabs/tensorflowjs-audio-codelab/index.html?index=..%2F..index#0

我要播放识别器具有的原始音频(下面的数据 代码)。 如何播放音频?

  recognizer.listen(async ({spectrogram: {frameSize,data}}) => {
  const vals = normalize(data.subarray(-16 * NUM_FRAMES));
  const input = tf.tensor(vals,[1,...INPUT_SHAPE]);
  const probs = model.predict(input);

  // want to play the sound here

  const predLabel = probs.argMax(1);
  console.log("predLabel : "+predLabel)
  tf.dispose([input,probs,predLabel]);
  
  },{
  overlapFactor: 0.5,includeSpectrogram: true,invokeCallbackOnNoiseAndUnknown: true
 });

样本数据

-60.036582946777344,-62.68927764892578,-61.65350341796875,-58.76688003540039,-59.08723831176758,-62.479156494140625,-66.66989135742188,-65.01232147216797,-56.5593147277832,-56.17310333251953,-66.192169189652578716 ,-57.67473602294922,-62.22568893432617,-67.1563720703125,-68.1759033203125,-67.30845642089844,-65.39064025878906,-67.94184875488281,-57.57915496826172,-53.876121520996094,-54.58951950073242,-57.5237464359-842359-5782898-592382-5782938592-5782938592-578-825-825-938-825-230-8253608-1、2378-3751、23451、2378-3752895-375-230-825-230-825-8253856-375-178-23086125-378-23086125-275 64.01222229003906,-77.53924560546875,-70.57168579101562,-75.01194763183594,-63.305816650390625,-60.46778869628906,-60.5777587890625,-65.36370086669922,-75.7658462524414,-70.79997253417969,-72.19499209692685-7685295685679-685-7685685-825-6852685-6895-265-6802685-6685-695-685-685-685-685-685-685-685-685-685-685-685-685-760-872-6002685-760-760-760-760-760-760-760-760-800-600-800-600-600-9006 -76.23112487792969,-65.46153259277344,-59.717864990234375,-61.3425 7507324219,-74.88931274414062,-61.08839416503906,-63.768775939941406,-58.36885452270508,-54.49985885620117,-56.87635803222656,-57.986724853515625,-55.69691467285156,-55.044151306152344,-56.78079605192-6856.5685742685265-685265-685265-450-825825-82516-825-760-760-825-760-160-825-180-760-760-760-160-760-180-180-760-760-760-760-760-760-760-760-760-760-760-760-760-760-108-760-760-760-108-108-760-760-120-760-760-108-108-108-108-108 -61.676536560058594,-60.09380340576172,-81.49282836914062,-63.019371032714844,-62.89784240722656,-61.531105041503906,-67.16841125488281,-71.91193389892578,-66.10831451416016,-62.600250244140625,-61.747299-10969559429569467524792675679654679-675685679-675685679-675685679-695很大->->->>>>> ,-59.653316497802734,-63.298248291015625,-60.50627136230469,-59.24553680419922,-62.05295181274414,-72.49028015136719,-63.31033706665039,-58.87725067138672,-61.649070739746094,-63.355079650878906,-63.687648773192-635-6679685679-635-6679760-679425-679425-695825679-635825-7603679-635825-760-635-760-635-760-635-760-635-760-635-760-365-186-365-760-365-186-365-186-365-186-365-186-186-760-186-178-178-178-178-178 65.8139877319336,-84.34310150146484,-77.82462 310791016,-65.11605072021484,-62.672061920166016,-61.65081024169922,-60.463748931884766,-60.061058044433594,-62.17293167114258,-65.4293441772461,-78.55030822753906,-69.18831634521484,-72.20611572265625,-84.086273972365972.6209728268562926972856856 -64.2643814086914,-64.13897705078125,-63.843544006347656,-62.497947692871094,-66.41625213623047,-66.47615051269531,-63.60227584838867,-63.583213806152344,-66.06173706054688.-68.21229553222656,-71.22559356-69067908760690760-93876065760-938760-760-760-3600-760-760-3600-760-760-350-760-760-350-760-760-760-760-350-760-760-230-760-350-760-230-760-230-7603556-3556 / 38403556 / 3840-1203840-9782938938938938 ,-79.84120178222656,-75.15550231933594,-67.77916717529297,-64.11933135986328,-62.128028869628906,-62.50722885131836,-60.23279571533203,-62.756874084472656,-65.1184310913086,-65.03284454345703,-73.4123687-6760679249787927606792679679692679 88.703369140625,-80.60435485839844,-74.93978118896484,-83。 31458282470703,-70.82904052734375,-67.49034118652344,-69.86143493652344,-69.34243774414062,-71.320388793945945,-78.449951171875,-82.94573974609375,-84.93756103515625,-74.5869369506836,-70.60111999511719,739.75872857685679685685695685685697685695-6858.2695-6856.8695-6856.8695-6856.8695-6856.8695-678685695-698694-695685695-698694-825所示-67.48170471191191406,-67.3597412109375,-70.356201171875,-73.6716537475586,-75.58068084716797,-73.56842803955078,-75.25067138671875,-71.17179870605469,-76.98733520507812,-77.32645416259766,-79.50026702880792898782782825829825829825985825985-825894-825894-825894-825894-825782-825894-825894-825782-825894-825782-825894-825782-82586-825685-178-825-178-178-178-178-178-178-178-178-178-178-178-178-178-178-178-760-178-178-760-178-178-178-178-178-178-180-760-180-680-178-178-178-180-178 ,-77.96391296386719,-75.00653076171875,-73.16362762451172,-71.91006469726562,-68.30740356445312,-68.11654663085938,-71.99263763427734,-70.73805236816406,-70.36695861816406,-70.08479309082031,-75.323-775-76075-76075-450-760-375-760-375-760-375-760-375-7603685-760-375-7603855-7603855-7603855-7603855-7603855 80.3564453125,-80.52128601074219,-78.54368591308594,-69.10721588 134766,-68.75949096679688,-73.78091430664062,-83.42097473144531,-75.11988830566406,-73.38346862792969,-77.39380645751953,-75.1491470336914,-77.40335845947266,-82.32390594482482422--76.90939331054688,-66.7509536743.6636377206377206375923872-6637909637-82576063-825-760-760-760-760-760-760-760-760-760-760-760-760-760-760-760-760-760-300-760 -72.04998016357422,-71.5898666381836,-88.53361511230469,-70.38175964355469,-66.68907928466797,-68.81939697265625,-77.65866088867188,-68.7597427368164,-61.67108917236328,-57.94376754760742,-59.2506790163823.6675.47275679-760327-760327-760327-450-6635679-760-375-760-375-760-760-375-760-760-760-760-375-760-760-760-760-760-760-760-760-760-760-360-760-760-760-360-760-760-360-760-760-760-378-760-378-378-378-350-78 ,-60.412288665771484,-56.49504089355469,-62.97809600830078,-61.028663635253906,-58.846717834472656,-64.03954315185547,-68.56185913085938,-62.053131103515625,-61.567596435546875,-65.60296630859375,-59.85504913336536536524955685365365-365365-365365-855-365855-635-855-635-855-635-855-855-230-855-855-855-855-230-855-855-855-125-360-855-230-855-855-230-855-855-125-855-135-118-135-855-118-360-855-855-125-855-135-125-118-3556 56.548805236816406,-56.98362731933594,-62.3466529846

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)