###前提・実現したいこと
C#での音声認識による波形の出力
###発生している問題・エラーメッセージ
https://teratail.com/questions/42564
上記の内容を参考にプログラムを作成しました。
エラーは発生していませんが、ビルドを行うと例外が発生してしまいます。
おそらく参照が足りていないのだと思いますが、何が足りていないのかが分かりません。
よろしければご教授お願い致します。
エラーメッセージ
型 'System.TypeLoadException' のハンドルされていない例外が System.Windows.Forms.dll で発生しました 追加情報:アセンブリ 'NAudio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' から型 'NAudio.Wave.WaveInCapabilities' を読み込めませんでした。
言語:C#
C#
1using NAudio.Wave; 2using OxyPlot; 3using OxyPlot.Axes; 4using OxyPlot.Series; 5using System; 6using System.Collections.Generic; 7using System.ComponentModel; 8using System.Data; 9using System.Drawing; 10using System.Linq; 11using System.Text; 12using System.Threading.Tasks; 13using System.Windows.Forms; 14 15namespace NAudio 16{ 17 18 public partial class Form1 : Form 19 { 20 public Form1() 21 { 22 InitializeComponent(); 23 } 24 25 private void Form1_Load(object sender, EventArgs e) 26 { 27 for (int i = 0; i < WaveIn.DeviceCount; i++) 28 { 29 var deviceInfo = WaveIn.GetCapabilities(i); 30 this.label1.Text = String.Format("Device {0}: {1}, {2} channels", 31 i, deviceInfo.ProductName, deviceInfo.Channels); 32 } 33 34 var waveIn = new WaveIn() 35 { 36 DeviceNumber = 0, // Default 37 }; 38 39 waveIn.WaveFormat = new WaveFormat(sampleRate: 8000, channels: 1); 40 waveIn.StartRecording(); 41 42 InitPlot(); 43 } 44 45 private PlotModel _plotmodel = new PlotModel(); 46 private LinearAxis _linearaxis1 = new LinearAxis 47 48 { 49 Position = AxisPosition.Bottom 50 }; 51 private LinearAxis _linearaxis2 = new LinearAxis 52 { 53 Minimum = -1.0, 54 Maximum = 1.0, 55 Position = AxisPosition.Left 56 }; 57 private LineSeries _lineSeries = new LineSeries(); 58 List<float> _recorded = new List<float>(); // 音声データ 59 60 private void InitPlot() 61 { 62 _plotmodel.Axes.Add(_linearaxis1); 63 _plotmodel.Axes.Add(_linearaxis2); 64 _plotmodel.Series.Add(_lineSeries); 65 this.plotView1.Model = _plotmodel; 66 } 67 68 private void ProcessSample(float sample) 69 { 70 _recorded.Add(sample); 71 72 if (_recorded.Count == 1024) 73 { 74 var points = _recorded.Select((v, index) => 75 new DataPoint((double)index, v) 76 ).ToList(); 77 _lineSeries.Points.Clear(); 78 _lineSeries.Points.AddRange(points); 79 80 this.plotView1.InvalidatePlot(true); 81 _recorded.Clear(); 82 } 83 } 84 } 85}
###補足情報(言語/FW/ツール等のバージョンなど)
C#(Visual Studio 2015 : Windows Form Application)
NuGetを用いてダウンロード
・NAudio ver1.8.0
・OxyPlot.Corever ver2.0.0-unstable0952
・OxyPlot.windowsForms ver2.0.0-unstable0952
回答1件
あなたの回答
tips
プレビュー