forked from cgvr/DeltaVR
Compare commits
3 Commits
843bd141eb
...
7be20d249e
| Author | SHA1 | Date | |
|---|---|---|---|
| 7be20d249e | |||
| 9c7536d1d4 | |||
| 0c026078d0 |
8
Assets/StreamingAssets/Whisper.meta
Normal file
8
Assets/StreamingAssets/Whisper.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 23fe3883e9cc804429bc54fb860d18f1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/StreamingAssets/Whisper/ggml-base.bin
Normal file
BIN
Assets/StreamingAssets/Whisper/ggml-base.bin
Normal file
Binary file not shown.
7
Assets/StreamingAssets/Whisper/ggml-base.bin.meta
Normal file
7
Assets/StreamingAssets/Whisper/ggml-base.bin.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f6c028f06eda5904eae3f7a7418b8416
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -5,7 +5,7 @@ public class ModelGenerationTestBox : MonoBehaviour
|
|||||||
public Material activeMaterial;
|
public Material activeMaterial;
|
||||||
public Material inactiveMaterial;
|
public Material inactiveMaterial;
|
||||||
public Transform modelSpawnPoint;
|
public Transform modelSpawnPoint;
|
||||||
public string inputPrompt;
|
public VoiceTranscriptionTestBox voiceTranscriptionTestBox;
|
||||||
|
|
||||||
private MeshRenderer meshRenderer;
|
private MeshRenderer meshRenderer;
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ public class ModelGenerationTestBox : MonoBehaviour
|
|||||||
{
|
{
|
||||||
meshRenderer.material = activeMaterial;
|
meshRenderer.material = activeMaterial;
|
||||||
|
|
||||||
|
string inputPrompt = voiceTranscriptionTestBox.currentTextOutput;
|
||||||
string modelPath = await PipelineManager.Instance.GenerateModelAsync(inputPrompt);
|
string modelPath = await PipelineManager.Instance.GenerateModelAsync(inputPrompt);
|
||||||
//LoadModel("D:\\henrisel\\DeltaVR3DModelGeneration\\3d-generation-pipeline\\models\\2025-11-17-16-13-33\\mesh.glb");
|
//LoadModel("D:\\henrisel\\DeltaVR3DModelGeneration\\3d-generation-pipeline\\models\\2025-11-17-16-13-33\\mesh.glb");
|
||||||
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(modelPath);
|
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(modelPath);
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using Whisper;
|
||||||
|
using Whisper.Utils;
|
||||||
|
|
||||||
|
public class VoiceTranscriptionTestBox : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Material activeMaterial;
|
||||||
|
public Material inactiveMaterial;
|
||||||
|
|
||||||
|
private MeshRenderer meshRenderer;
|
||||||
|
|
||||||
|
|
||||||
|
public WhisperManager whisper;
|
||||||
|
public MicrophoneRecord microphoneRecord;
|
||||||
|
public TextMeshProUGUI outputText;
|
||||||
|
|
||||||
|
private string _buffer;
|
||||||
|
public string currentTextOutput;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
whisper.OnNewSegment += OnNewSegment;
|
||||||
|
whisper.OnProgress += OnProgressHandler;
|
||||||
|
|
||||||
|
microphoneRecord.OnRecordStop += OnRecordStop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
meshRenderer = GetComponent<MeshRenderer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
KbmController controller = other.GetComponent<KbmController>();
|
||||||
|
if (controller != null)
|
||||||
|
{
|
||||||
|
meshRenderer.material = activeMaterial;
|
||||||
|
microphoneRecord.StartRecord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerExit(Collider other)
|
||||||
|
{
|
||||||
|
KbmController controller = other.GetComponent<KbmController>();
|
||||||
|
if (controller != null)
|
||||||
|
{
|
||||||
|
meshRenderer.material = inactiveMaterial;
|
||||||
|
microphoneRecord.StopRecord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void OnRecordStop(AudioChunk recordedAudio)
|
||||||
|
{
|
||||||
|
_buffer = "";
|
||||||
|
|
||||||
|
var sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
|
||||||
|
var res = await whisper.GetTextAsync(recordedAudio.Data, recordedAudio.Frequency, recordedAudio.Channels);
|
||||||
|
if (res == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var time = sw.ElapsedMilliseconds;
|
||||||
|
var rate = recordedAudio.Length / (time * 0.001f);
|
||||||
|
UnityEngine.Debug.Log($"Time: {time} ms\nRate: {rate:F1}x");
|
||||||
|
|
||||||
|
var text = res.Result;
|
||||||
|
|
||||||
|
currentTextOutput = text;
|
||||||
|
outputText.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnProgressHandler(int progress)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log($"Progress: {progress}%");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNewSegment(WhisperSegment segment)
|
||||||
|
{
|
||||||
|
_buffer += segment.Text;
|
||||||
|
UnityEngine.Debug.Log(_buffer + "...");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d28857190597d9a46a8ddf3cf902cc81
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
57
Assets/_PROJECT/Scripts/Audio/VoiceTranscription.cs
Normal file
57
Assets/_PROJECT/Scripts/Audio/VoiceTranscription.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using UnityEngine;
|
||||||
|
using Whisper;
|
||||||
|
using Whisper.Utils;
|
||||||
|
|
||||||
|
public class VoiceTranscription : MonoBehaviour
|
||||||
|
{
|
||||||
|
public WhisperManager whisper;
|
||||||
|
public MicrophoneRecord microphoneRecord;
|
||||||
|
|
||||||
|
private string _buffer;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
whisper.OnNewSegment += OnNewSegment;
|
||||||
|
|
||||||
|
microphoneRecord.OnRecordStop += OnRecordStop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnRecordStop(AudioChunk recordedAudio)
|
||||||
|
{
|
||||||
|
_buffer = "";
|
||||||
|
|
||||||
|
var sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
|
||||||
|
var res = await whisper.GetTextAsync(recordedAudio.Data, recordedAudio.Frequency, recordedAudio.Channels);
|
||||||
|
if (res == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var time = sw.ElapsedMilliseconds;
|
||||||
|
var rate = recordedAudio.Length / (time * 0.001f);
|
||||||
|
UnityEngine.Debug.Log($"Time: {time} ms\nRate: {rate:F1}x");
|
||||||
|
|
||||||
|
var text = res.Result;
|
||||||
|
|
||||||
|
UnityEngine.Debug.Log(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNewSegment(WhisperSegment segment)
|
||||||
|
{
|
||||||
|
_buffer += segment.Text;
|
||||||
|
UnityEngine.Debug.Log(_buffer + "...");
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/_PROJECT/Scripts/Audio/VoiceTranscription.cs.meta
Normal file
11
Assets/_PROJECT/Scripts/Audio/VoiceTranscription.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af83274dbfe8bab4599dda694e2545c2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
"com.unity.xr.mock-hmd": "1.3.1-preview.1",
|
"com.unity.xr.mock-hmd": "1.3.1-preview.1",
|
||||||
"com.unity.xr.oculus": "3.2.3",
|
"com.unity.xr.oculus": "3.2.3",
|
||||||
"com.unity.xr.openxr": "1.7.0",
|
"com.unity.xr.openxr": "1.7.0",
|
||||||
|
"com.whisper.unity": "https://github.com/Macoron/whisper.unity.git?path=/Packages/com.whisper.unity",
|
||||||
"com.unity.modules.ai": "1.0.0",
|
"com.unity.modules.ai": "1.0.0",
|
||||||
"com.unity.modules.androidjni": "1.0.0",
|
"com.unity.modules.androidjni": "1.0.0",
|
||||||
"com.unity.modules.animation": "1.0.0",
|
"com.unity.modules.animation": "1.0.0",
|
||||||
|
|||||||
@@ -388,6 +388,13 @@
|
|||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
"com.whisper.unity": {
|
||||||
|
"version": "https://github.com/Macoron/whisper.unity.git?path=/Packages/com.whisper.unity",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "git",
|
||||||
|
"dependencies": {},
|
||||||
|
"hash": "529a628a915a97799e89e061af9cb7c71407124d"
|
||||||
|
},
|
||||||
"com.unity.modules.ai": {
|
"com.unity.modules.ai": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user