{"id":24702538,"url":"https://github.com/yankeguo/volcvoice","last_synced_at":"2025-03-22T04:24:30.343Z","repository":{"id":262068231,"uuid":"886133951","full_name":"yankeguo/volcvoice","owner":"yankeguo","description":"A Go Library for Volcengine (Bytedance) Voice Service","archived":false,"fork":false,"pushed_at":"2024-11-12T16:30:11.000Z","size":334,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T05:41:44.607Z","etag":null,"topics":["tts","tts-api","volcengine"],"latest_commit_sha":null,"homepage":"https://www.volcengine.com/docs/6561/133350","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yankeguo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"yankeguo","patreon":"yankeguo"}},"created_at":"2024-11-10T09:43:20.000Z","updated_at":"2024-11-12T16:30:01.000Z","dependencies_parsed_at":"2024-11-10T15:32:37.687Z","dependency_job_id":null,"html_url":"https://github.com/yankeguo/volcvoice","commit_stats":null,"previous_names":["yankeguo/vevoice","yankeguo/volcvoice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fvolcvoice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fvolcvoice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fvolcvoice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo%2Fvolcvoice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yankeguo","download_url":"https://codeload.github.com/yankeguo/volcvoice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244905081,"owners_count":20529539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tts","tts-api","volcengine"],"created_at":"2025-01-27T05:41:33.556Z","updated_at":"2025-03-22T04:24:30.316Z","avatar_url":"https://github.com/yankeguo.png","language":"Go","funding_links":["https://github.com/sponsors/yankeguo","https://patreon.com/yankeguo"],"categories":[],"sub_categories":[],"readme":"# volcvoice\n\nA Go Library for Volcengine (Bytedance) Voice Service\n\n## Notes\n\n**PCM output format**\n\n`16-bit signed integer, little-endian, mono`, default to `24k` sample rate.\n\nExample ffmpeg command:\n\n```\nffmpeg -f s16le -ar 24k -ac 1 -i test.pcm test.mp3\n```\n\n## Usages\n\n**Create Client**\n\n```go\n// using VOLCVOICE_APPID and VOLCVOICE_TOKEN\nclient := volcvoice.NewClient()\n\n// explicit set appid and token\nclient := volcvoice.NewClient(\n    volcvoice.WithAppID(\"your_app_id\"),\n    volcvoice.WithToken(\"your_token\"),\n)\n```\n\n**Voice Clone Upload**\n\n```go\nservice := client.VoiceCloneUpload().\n\tSetSpeakerID(os.Getenv(\"VOLCVOICE_SPEAKER_ID\")).\n\tAddAudio(buf, FormatMP3, \"\").\n\tSetModelType(VoiceCloneUploadModelTypeV2)\n\nerr := service.Do(context.Background())\n```\n\n**Stream Synthesize**\n\n```go\nservice := client.StreamSynthesize().\n\tSetInput(`“水何澹澹，山岛竦峙。树木丛生，百草丰茂。秋风萧瑟，洪波涌起”是实写眼前的景观，神奇而又壮观。“水何澹澹，山岛竦峙”是望海初得的大致印象，有点像绘画的轮廓。`).\n\tSetFormat(FormatPCM).\n\tSetRequestID(requestId.String()).\n\tSetCluster(StreamSynthesizeClusterV2).\n\tSetUserID(\"test\").\n\tSetSpeakerID(os.Getenv(\"VOLCVOICE_SPEAKER_ID\")).\n\tSetOutput(func(ctx context.Context, buf []byte) (err error) {\n\t\tt.Logf(\"len(buf): %d\", len(buf))\n\t\t_, err = f.Write(buf)\n\t\treturn\n\t})\n\nerr := service.Do(context.Background())\n```\n\n**Bi-directional Stream Synthesize**\n\n```go\nvar (\n\tinput = []string{\n\t\t\"离离原上草，一岁一枯荣。\",\n\t\t\"野火烧不尽，春风吹又生。\",\n\t\t\"远芳侵古道，晴翠接荒城。\",\n\t\t\"又送王孙去，萋萋满别情。\",\n\t}\n\tinputIdx int64 = -1\n)\n\nservice := client.DuplexSynthesize().\n\tSetResourceID(SynthesizeResourceVoiceClone2).\n\tSetRequestID(rg.Must(uuid.NewV7()).String()).\n\tSetConnectID(rg.Must(uuid.NewV7()).String()).\n\tSetFormat(AudioFormatPCM).\n\tSetSampleRate(SampleRate16K).\n\tSetSpeakerID(os.Getenv(\"VOLCVOICE_SPEAKER_ID\")).\n\tSetInput(func(ctx context.Context) (chunk string, err error) {\n\t\tidx := atomic.AddInt64(\u0026inputIdx, 1)\n\t\tif idx \u003e= int64(len(input)) {\n\t\t\terr = io.EOF\n\t\t\treturn\n\t\t}\n\t\ttime.Sleep(400 * time.Millisecond)\n\t\tchunk = input[idx]\n\t\treturn\n\t}).\n\tSetOutput(func(ctx context.Context, chunk []byte) (err error) {\n\t\t_, err = f.Write(chunk)\n\t\treturn\n\t}).\n\tSetUserID(\"test-user\")\n\nerr := service.Do(context.Background())\n```\n\n## Credits\n\nGUO YANKE, MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyankeguo%2Fvolcvoice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyankeguo%2Fvolcvoice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyankeguo%2Fvolcvoice/lists"}